Do you know how to export and import MySQL data under the Ubuntu command line? The following is the method compiled by the editor for importing and exporting databases under the Ubuntu command line. Let’s learn it together!
-p or --port The server port to be connected. If the MySQL port is not 3306, you must use this parameter -d or -- no-data No detailed data, just export the structure of the data
--add-drop-table When creating a table, first drop the existing table with the same name [usually followed by the -d parameter]
The following is example Take the database as an example to do an export example:
1. Export all data of the entire example database (including table structure, including data)
mysqldump -h 127.0.0.1 -u root -p example > example.sql
mysqldump -h 127.0.0.1 -u root -p -d --add-drop-table example > example.sql
Connect to MySQL:
mysql -u root -p
CREATE DATABASE example;(数据库名可以不一样)
use example;
mysql>source /path/example.sql;
The above is the detailed content of MySQL data export and import statements under Ubuntu command line. For more information, please follow other related articles on the PHP Chinese website!