免交互 -e
[root@localhost system]# mysql -uroot -p -e "show databases;"
Enter password:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
恢复数据 <
mysql -uroot -p 123456 < /root/abc.sql
mysql> source /root/abc.sql #恢复数据
mysql> help #查看帮助命令
备份 恢复也可以用这个< 符号换一下,注意连接地址。
mysqldump -h 10.0.2.251 -uroot -p --set-gtid-purged=off --opt -R --default-character-set=utf8 --hex-blob --single-transaction kuming> ./kuming.sql
#\G一行显示不完,可以让它竖起来显示
mysql> select user,host from mysql.user\G;
*************************** 1. row ***************************
user: root
host: %
*************************** 2. row ***************************
user: peng
host: 10.0.%
*************************** 3. row ***************************
user: zhiuan
host: 10.0.2.%
*************************** 4. row ***************************
user: mysql.session
host: localhost
*************************** 5. row ***************************
user: mysql.sys
host: localhost
5 rows in set (0.00 sec)