How to Import and Export mysql Database in linux
This article mainly shows you "how to import and export mysql database in linux", the content is simple and easy to understand, clear organization, I hope to help you solve doubts, let Xiaobian lead you to study and learn "how to import and export mysql database in linux" this article bar.
1. Export the database with the mysqldump command (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
Enter will prompt for password
2. Export only 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/ -> mysql data directory
II. Import database
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) Import data (note the path of sql file)
mysql>source /home/abc/abc.sql;
Method 2:
mysql -u username-p password database name mysql -uabc_f -p abc < abc.sql It is recommended to import using the second method. Note: There is command line mode, there is sql command The above is "how to import and export mysql database in linux" all the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!