13.4 mysql用户管理 13.5 常用sql语句 13.6 mysql数据库备份恢复

其中,all表示所有的权限(如读、写、查询、删除等操作);.有2个*,前者表示所有的数据库,后者所有的表;identified by后面跟密码,用单引号括起来。这里的user1特指localhost上的user1。

默认socket连接

不需要-h也能登陆啦

show grants;其实看的是root用户的。

查看指定用户的授权

如果user2除了要在128上登录,还要在129上登录,那该怎么办?

select * from mysql.db where host like '192.168.%'G;

 创建表t1;

[root@lizhipenglinux01 ~]# mysqldump -uroot -paminglinux mysql > /tmp/mysqlbak.sql     数据库备份到/tmp/mysqlbak.sql
Warning: Using a password on the command line interface can be insecure.

[root@lizhipenglinux01 ~]# mysql -uroot -paminglinux -e "create database mysql2"            创建数据库mysql2
Warning: Using a password on the command line interface can be insecure.

[root@lizhipenglinux01 ~]# mysql -uroot -paminglinux mysql2 < /tmp/mysqlbak.sql             备份的数据库恢复到mysql2
Warning: Using a password on the command line interface can be insecure.

登录时所在数据库就是mysql2

先库后表

[root@lizhipenglinux01 ~]# mysqldump -uroot -paminglinux mysql user > /tmp/user.sql    备份user表
Warning: Using a password on the command line interface can be insecure.

只有库没有表

[root@lizhipenglinux01 ~]# mysql -uroot -paminglinux mysql2 < /tmp/user.sql       恢复
Warning: Using a password on the command line interface can be insecure.

备份所有库

备份表结构 -d

原文地址:https://www.cnblogs.com/sisul/p/8594776.html