MySQL导入、导出sql命令

1、在登录到服务器后,操作MySQL数据库,按照如下步骤导入sql文件(记得改为自己实际的sql文件路径)

[root@vultr bin]# ./mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use wgcloud;
Database changed
mysql> source /wgcloudTest/v3.3.7_to_v3.3.8.sql;
Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> 

	
2、如果我们要备份数据库的话,使用MySQL提供的导出工具mysqldump即可,如下进入到MySQL安装目录bin下操作

[root@vultr bin]# ./mysqldump -uroot -p wgcloud > /home/wgcloud.sql
Enter password: