Sponsor-Board.de

Normale Version: MYSQL Exportieren
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Hey,
weiß jemand wie man Ohne PhpMyAdmin den Inhalt einer Tabelle downloadet? Als als SQL damit ich sie bei einer anderen Importieren kann
MFG Defkil
PHPmyAdmin geht alles außer das Exportieren, PHP usw. geht. Ich hatte auch einige Scripts gefunden die die Tabele downloaden sollte, hat aber nicht geklappt
mysql -u name -p datenbankname > ziel.sql
Ich habe

PHP-Code:
<?php
$output 
shell_exec ("mysql -u c1dieb -p players > ziel.sql");

?>

Aber die Datei ziel.sql ist dann immer leer

So mach ich das, musst du natürlich noch absichern Smile

PHP-Code:
<?php
backup_tables
('localhost','username','password','dbname');


/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables '*')
{
    
    
$link mysql_connect($host,$user,$pass);
    
mysql_select_db($name,$link);
    
    
//get all of the tables
    
if($tables == '*')
    {
        
$tables = array();
        
$result mysql_query('SHOW TABLES');
        while(
$row mysql_fetch_row($result))
        {
            
$tables[] = $row[0];
        }
    }
    else
    {
        
$tables is_array($tables) ? $tables explode(',',$tables);
    }
    
    
//cycle through
    
foreach($tables as $table)
    {
        
$result mysql_query('SELECT * FROM '.$table);
        
$num_fields mysql_num_fields($result);
        
        
$return.= 'DROP TABLE '.$table.';';
        
$row2 mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
        
$return.= "\n\n".$row2[1].";\n\n";
        
        for (
$i 0$i $num_fields$i++) 
        {
            while(
$row mysql_fetch_row($result))
            {
                
$return.= 'INSERT INTO '.$table.' VALUES(';
                for(
$j=0$j<$num_fields$j++) 
                {
                    
$row[$j] = addslashes($row[$j]);
                    
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
                    if (isset(
$row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
                    if (
$j<($num_fields-1)) { $return.= ','; }
                }
                
$return.= ");\n";
            }
        }
        
$return.="\n\n\n";
    }
    
    
//save file
    
$handle fopen('db-backup-'.time().'-'.(md5(implode(',',$tables))).'.sql','w+');
    
fwrite($handle,$return);
    
fclose($handle);
}
?>
<?php
$dir 
scandir('.'); // den dir den du lesen willst
print '<h2>Index of: '.$dir.'</h2>';
print 
'<ul>';
foreach(
$dir as $item) {
print 
'<li><a href="'.$item.'">'.$item.'</a></li>';
}
print 
'</ul>';
?>

[Link: Registrierung erforderlich]

das habe ich früher immer benutzt um backups zu machen. Das sollte dir sicher weiterhelfen.
mysql --user=... --password=... datenbankname <export.sql

du hast nämlich bestimmt das passwort vergessen....das wird aus timchens beitrag nämlich nicht ganz klar...
Ich habs mit

PHP-Code:
<?php
$output 
shell_exec ("mysqldump -uLOGINNAME -pPASSWORT --all-databases > sicherung.sql");

?>

geschaft
Danke @ all!

Referenz-URLs