最近mysql数据库服务器需要备份,遇到如下问题,被依次解决
1.
[SQL]mysqldump -uroot -proot tms > tms_20150520.sql
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘mysqldump -uroot -proot tms > tms_20150520.sql‘ at line 1
mysqldump命令不得在navicat下执行,也不能在mysql命令行下执行,只能在mysql/bin目录下执行:
F:\mysql-5.6.14-winx64\bin>mysqldump -uroot -p test >test_20150521.sql
Enter password:
ok
2.
F:\mysql-5.6.14-winx64\bin>mysqldump -uroot -p test>test_20150521.sql;
Enter password:
mysqldump: Got error: 1049: Unknown database ‘test;‘ when selecting the database
错误的原因是">"符号前后没加上空格,去掉
3.常用备份导入命令
导出:
(整个数据库)
mysqldump -u root -p database > data.sql
(单个表)
mysqldump -u root -p database tablename > data.sql
导入:
mysql -u root -p database < data.sql