不要进入MySQL界面:(登录之前执行命令)
导出数据库
mysqldump -u root -p test > /test-data.sql;
导入数据库
mysqldump -u root -p test < /test-data.sql;
- -u:登录账号
- -p:登录密码(在命令行不输入,回车后输入)
- test:要导出的数据库名称
- test-data:导出的sql文件
进入MySQL导入
mysql -u root -p ; //登录mysql
****** // 输入登录密码
use test; // 选择数据库名称
source /test-data.sql; //导入命令