Source: http://bbs.mysql.cn/viewthread.php? Tid = 72 & extra = Page % 3d1% 26 filter % 3 ddigest
About Mysql Data export and version Conversion
Recently, many people have been asking about MySQL import and export, So I simply summarized some of my usage experience for your reference. If there is anything unreasonable, please contact us!
I. MySQL DATA Export
Some webmasters often use the most direct method of copying database folders. This method is simple, but it is not recommended that it is prone to problems in cross-version or cross-Character Set Systems. Besides, database 4.1 has two data storage methods available during configuration. One is to store the same data inventory as before in a separate folder, another is what I forgot. All these databases are put in one file, a huge file !, So the latter cannot use the copy method. What should I use? The following describes:
Mysqldump is the MySQL tool. It is very powerful and can export data, and can export data of different versions or other databases. This tool is actually used in command line and cmd. If your msyql/bin directory is not configured in the system environment variable, CD to the MySQL/bin directory first.
1. First, we will introduce how to export: mysqldump-u database username-P database name [Table name]> path name of the exported file.
For example, I want to export the database test_db. My database user is root and has no password (no-P is required if there is no password ):
Mysqldump-u root test_db> C:/test. SQL so that you can test the database everywhere.
If I want to export the user table in the test database, the user password ajin is 123.
Mysqldump-u ajin-P test_db user> C:/test_user_table. SQL press enter and prompt to enter the password.
2. Change the default Character Set of the database during the export process.
For example, I want to export the conversion code of the database test_db to utf8 (utf8 is my most commonly used)
Mysqldump-u ajin-p -- default-character-set = utf8 test_db> C:/test. SQL.
To convert to other characters, you only need to replace utf8.
3. Export data of different versions or data exported to the database
For example, in my database MySQL 4.1, I want to export data of Version 4.0 of the default Character Set utf8.
Mysqldump-u ajin-P test_db -- compatible = mysql40 -- default-character-set = utf8 test_db> C:/test. SQL
The so-called downgrade-compatible = can be followed by mysql323 mysql40 Oracle MSSQL DB2, etc.
Export introduces these common ones, but there are many more .. Omit one thousand words .....
Data Import
This is relatively simple. It is used in command line and cmd. If your msyql/bin directory is not configured in the system environment variables, CD to the MySQL/bin directory first.
For example, I want to import the data test. SQL to the discuz_db database.
Mysql-u ajin-P discuz_db <C:/test. SQL press enter to enter the password. If there is no password,-P is not required.
Now, let's sum up so much. You are welcome to talk about it, but there will inevitably be errors. Please kindly advise ~~