command-line Export database:
1, into the MySQL directory under the Bin folder: cd MySQL to the Bin folder directory
As I entered the command line: CD C:/Program files/mysql/mysql Server 4.1/bin
2, Export database: Mysqldump-u user name-p database name > exported file name
As I entered the command line: Mysqldump-u root-p News > News.sql (Input will allow you to enter the password into MySQL)
(If you export a single table, enter the table name after the database name)
3, will see the file News.sql automatically generated to the bin file
Command line Import Database:
1, to move the imported. sql file to the bin file, this is a convenient path
2, the 1th step with the above export
3, enter mysql:mysql-u user name-P
As I entered the command line: Mysql-u root-p (Enter the same will let you enter the Ysql password)
4, create the database you want to build in Mysql-front, this is an empty database, such as a new target database named News
5, enter: Mysql>use Target database name
As I entered the command line: Mysql>use news;
6, import file: Mysql>source import of the file name;
As I entered the command line: Mysql>source news.sql;
Import will have problems in Chinese, so it is best to convert to Utf-8 before importing, and you need to set the import format when importing:
First stop MySQL service: sudo/etc/init.d/mysql stop
Then edit the MySQL configuration file: sudo gedit/etc/mysql/my.cnf
Add under [Client] section in MY.CNF file
Default-character-set=utf8
[Mysqld_safe]
Default-character-set=utf8
[Mysqld]
Default-character-set=utf8
[MySQL]
Default-character-set=utf8
Restart the MySQL service,
Sudo/etc/init.d/mysql start
Enter the following instructions at the MySQL command prompt:
Mysql>show variables like '%char% ';
If the contents of the list appear the same as the following indicates that the configuration was successful,
+----------------------+---------------------
| variable_name | Value
+-----------------------+---------------------
| character_set_client | Utf8
| character_set_connection | Utf8
| Character_set_database | Utf8
| Character_set_filesystem | Binary
| Character_set_results | Utf8
| Character_set_server | Utf8
| Character_set_system | Utf8
| Character_sets_dir | /usr/share/mysql/charsets/
Then delete the original database, and then new (I do this, do not do or will be wrong)
Now the Chinese data can be inserted.
remember, after modifying the my.cnf file, be sure to reboot the MySQL server. Otherwise, the editor is not effective.