Here are two ways to describe each.
Linux under:
2. Method one SQL script form
Action steps are as follows:
2.1. Export SQL Script
On the original database server, you can export the SQL script using the phpMyAdmin tool, or the mysqldump command line (mysqldump command in the mysql/bin/directory).
2.1.1 with phpMyAdmin Tools
Export options, select export structure and data, and do not add drop DATABASE and drop TABLE options.
Select the Save As File option to select the gzipped option if the data is more numerous.
Save the exported SQL file.
2.1.2 with mysqldump command line
Command format
Mysqldump-u user name-p database name > database name. sql
Example:
MYSQLDUMP-UROOT-P ABC > Abc.sql
(Export database ABC to abc.sql file)
When prompted for a password, enter the password for the database user name.
2.2. Create an empty database
Create a database from the Master interface/Control Panel. Suppose the database is named ABC and the database is Abc_f.
2.3. Import SQL script into execution
There are also two methods, one using the phpMyAdmin (MySQL database management) tool, or the MySQL command line.
2.3.1 with phpMyAdmin Tools
From the Control Panel, choose to create an empty database, click "Manage", and go to the admin tools page.
On the SQL menu, browse to select the SQL file you just exported and click "Execute" to download and execute.
Note: phpMyAdmin has limits on the size of uploaded files, and PHP itself has limits on the size of uploaded files, if the original SQL file
Relatively large, you can first use gzip to compress it, for SQL files such as text files, you can get 1:5 or higher compression rate.
Gzip Use method:
# gzip Xxxxx.sql
Get
xxxxx.sql.gz files.
2.3.2 with mysql command line
Command format
Mysql-u user name-p database name < database name. sql
Example:
MYSQL-UABC_F-P ABC < Abc.sql
(Import database ABC from Abc.sql file)
When prompted for a password, enter the password for the database user name.
3 Method Two direct copies
If the database is large, you can consider using a direct copy method, but the different versions and operating systems may be incompatible between the use of caution.
3.1 Preparation of original documents
Packaged in tar as a file
3.2 Creating an empty database
3.3 Decompression
Unzip in the temp directory, such as:
Cd/tmp
Tar zxf mydb.tar.gz
3.4 copies
Copy 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 document copying the past to Mysql:mysql, with the permission changed to 660
Chown mysql:mysql/var/lib/mysql/mydb/*
chmod 660/var/lib/mysql/mydb/*
Revise the mysqldump out of the data. In addition to adding the table) Type=myisam CHARACTER set GBK, add a set NAMES GBK below;
In this way, the data can be smoothly imported 4.1, without fear of garbled.
Under Windows:
DOS window
Start-> Run-> cmd
Exported as: Mysqldump-u User name-p–opt database username > database name. sql
Enter your database password!
Import as: Mysql-u user name-P database username < database name. SQL (to operate in the current directory)
Other methods on the network
Back up the database (including all tables and all stored procedures):
C:documents and Settingsadministrator>mysqldump-h localhost-u root-p-R bannei >d:/
Log/mydb.sql
Enter Password: Hu Jintao
Back up all tables in the database
C:documents and Settingsadministrator>mysqldump-h localhost-u root-p jxhxt >d:/log/bn2010-01-29.sql
Enter Password: Hu Jintao
Backing up specified table data in a database
C:documents and Settingsadministrator>mysqldump-h localhost-u root-p jxhxt invite_mail >d:/log/bn2010-01-29.sql
Enter Password: Hu Jintao
Back up all stored procedures
C:documents and Settingsadministrator>mysqldump-h localhost-u root-p-t-d-R bannei >d:/log/myproc.sql
Enter Password: Hu Jintao
Export a database structure
C:documents and Settingsadministrator>mysqldump-u root-p-D--add-drop-table ruyi_db>d:ruyi_db.sql
Import data files
C:documents and Settingsadministrator>mysql-h localhost-u root-p bannei <d:/log/mydb.sql
Enter Password: Hu Jintao
Import database, Common Source command
Access the MySQL database console, such as Mysql-u root-p
Mysql>use Database
Then use the source command, followed by the script file (such as the. SQL used here)
Mysql>source D:ruyi_db.sql
This article about the MySQL mysqldump I will not say more, we can search the site on the mysqldump specific parameters and usage.