How to import and export mysql database

WBOY
Release: 2023-05-28 14:16:53
forward
2686 people have browsed it

1. Database import

mysql -uroot -p123456 --default-character-set=utf8 test123
Copy after login

2. Database export

  • Export the entire database

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

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

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

-d Export empty table

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

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.
Copy after login

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
Copy after login
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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!