Home >Database >Mysql Tutorial >How to import and export mysql database

How to import and export mysql database

WBOY
WBOYforward
2023-05-28 14:16:532783browse

1. Database import

mysql -uroot -p123456 --default-character-set=utf8 test123

2. Database export

  • Export the entire database

mysqldump -uroot -p123456 test123> test123.sql
  • Export database single table

mysqldump -uroot -p123456 test123log> test123_log.sql
  • Export database table structure

mysqldump -uroot -p123456 -d --add-drop-table test123> test123.sql

-d Export empty table

--add-drop-table 每个数据表创建之前添加drop数据表语句

3. Problem record

When mysqldump is exported from the command line, if you enter a password, the following warning message will be prompted (it has been executed successfully, but the warning message will be prompted)

Warning: Using a password on the command line interface can be insecure.

3.1. Repair method

  • When exporting from the command line, manually enter the password

  • In /etc/mysql/my Append

[mysqldump]
user=user_name
password=password
at the end of the .cnf file.

The above is the detailed content of How to import and export mysql database. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete