1. Use the mysqldump command to export the database (note the installation path of mysql, that is, the path of this command):
1. Export data and table structure:
mysqldump -u username -p password database name > database name.sql
#/usr/local/ mysql/bin/ mysqldump -uroot -p abc > abc.sql
After pressing Enter, you will be prompted to enter the password
2. Only export the table structure
mysqldump -u username -p password -d database name > database
name.sql #/usr/local/mysql/bin/ mysqldump -uroot -p -d abc > abc.sql
Note: /usr/local/mysql/bin/ ---> data directory of mysql
Second, import the database
1, first create an empty database
mysql>create database abc;
2. Import database
method 1:
(1) Select database
mysql>use abc;
(2) Set database code
mysql>set names utf8;
(3) Build the corresponding fields
(4) Import data (pay attention to the path of the sql file)
mysql>source /home/abc/abc.sql;
Method 2:
mysql -u username -p password database name < database name.sql
#mysql -uabc_f -p abc < abc.sql
It is recommended to import using the second method.
Note: There is a command line mode, there are sql commands