Importing data under Windows
(i) Export
Command: Mysqldump-u user name-p database name > filename
If the username requires a password, you need to enter a password check after this command is executed, and if the database username does not require a password, do not add the "-P" parameter and import the same. Note The user name you enter needs to have operational rights to the corresponding database, or you cannot export the data. As a result of system maintenance and the export of all databases, we usually use root and other super user rights.
For example, to export the ABC database to a database file named Db_abc.sql in the current directory, enter the following command:
#mysqldump-u root-p ABC > Db_abc.sql
If you want to export sql.zip or gzip format files directly, the following commands are:
Enter the mysqlbin> directory: mysqldump-u root-p b766951_apple >gzip > XX.sql.gzip
Enter Password: ********
Next, enter the root user's password to export the database.
(ii) Import
Command: Mysql-u user name-p database name < filename
The same as the mysqldump command, the meaning of each parameter with mysqldump.
For example, to import data from the/root/backup/db_abc.sql file into the ABC database, use the following command:
#mysql-u root-p ABC </root/backup/db_abc.sql or back <gzip < XX.sql.gzip
Importing data in Linux
If the database is large, consider using a direct copy method, but the different versions and operating systems may be incompatible, and should be used with caution.
3.1 Prepare original file
with tar package for a file
3.2 create empty database
3.3 Extract
Extract in temp directory, such as:
cd/tmp
Tar zxf mydb.tar.gz
3.4 copy copies the extracted database files to the related directory
CD mydb/
CP */var/lib/mysql/mydb/
for FreeBSD:
CP */var/db/mysql/mydb/
3.5 permission Settings change the owner of the file that copied the past to Mysql:mysql, change the permission to 660
Chown mysql:mysql/var/lib/mysql/mydb/*
chmod 660/var/lib/mysql/mydb/*
Change the mysqldump data. In addition to adding the table) Type=myisam CHARACTER set GBK, add a set NAMES GBK below;
This way, the data can be smoothly imported into 4.1 without fear of garbled characters.