MySQL command line to export the database: 1, enter the bin folder under the MySQL Directory: cd MySQL to the bin folder directory, such as the command line I entered: cd C: \ Program Files \ MySQL Server 4.1 \ bin (or directly add the directory to the windows environment variable path) www.2cto.com 2, export the database: mysqldump-u username-p Database Name> the exported file name is shown in the command line: mysqldump-u root-p news> news. SQL (you will be asked to enter the MySQL password after the input) (if you export a single table, enter the table name after the database name)
3. The file news. SQL is automatically generated under the binfile.
Command Line import database: 1, to be imported. move the SQL file to the binfile. This path is more convenient. 2. Go to Step 1 www.2cto.com 3, and export the SQL file to MySQL: mysql-u username-p, as shown in the command line I entered: mysql-u root-p (after entering the same password, you will be asked to enter the MySQL password) 4. Create the database you want to create in MySQL-Front. In this case, the database is empty, for example, if you create a target database named "news" 5, enter mysql> use target database name, for example, the command line I enter: mysql> use news; 6. Import the file: the file name imported from mysql> source, for example, mysql> source news. SQL; MySQL backup and restoration are completed using mysqldump, mysql, and source commands.
1. MySQL backup and restoration under Win32
1.1 backup Start Menu | run | cmd | use the "cd \ Program Files \ MySQL Server 5.0 \ bin" command to enter the bin folder | use "mysqldump-u username-p databasename> exportfilename "export the database to a file, for example, mysqldump-u root-p voice> voice. SQL, and then enter the password to start exporting. 1.2 restore to MySQL Command Line Client, enter the password, go to "mysql>", enter the Command "show databases;", Press enter to see what database; create the database you want to restore, enter "create database voice;", Press ENTER; switch to the database you just created, enter "use voice;", Press ENTER; import data, and enter "source voice. SQL; ", Press enter to start importing, and" mysql> "is displayed again. If no error is returned, the restoration is successful. 2. MySQL backup and restoration in Linux
2.1 Back Up www.2cto.com [root @ localhost ~] # Cd/var/lib/mysql (go to the MySQL database directory and adjust the directory based on your MySQL installation) [root @ localhost mysql] # mysqldump-u root-p voice> voice. SQL, enter the password. 2.2 Reduction Method 1: [root @ localhost ~] # Mysql-u root-p press enter and enter the password to go To the MySQL console "mysql>", which is restored in the same way as 1.2. Method 2: [root @ localhost ~] # Cd/var/lib/mysql (go to the MySQL database directory and adjust the directory based on your MySQL installation) [root @ localhost mysql] # mysql-u root-p voice <voice. SQL, enter the password. Author seraphim. leo