mysql用户管理
MySQL创建用户以及授权
grant all on . to ‘user1’ identified by ‘passwd’;
grant SELECT,UPDATE,INSERT on db1. to ‘user2’@’192.168.133.1’ identified by ‘passwd’;
grant all on db1.
to ‘user3’@’%’ identified by ‘passwd’;
show grants;
show grants for [email protected];

常用sql语句
select count() from mysql.user;
select
from mysql.db;
select db from mysql.db;
select db,user from mysql.db;
select * from mysql.db where host like ‘192.168.%’;
insert into db1.t1 values (1, ‘abc’);
update db1.t1 set name=’aaa’ where id=1;
truncate table db1.t1;
drop table db1.t1;
drop database db1;

FLUSH PRIVILEGES

mysql数据库备份恢复
备份库 mysqldump -uroot -p123456 mysql > /tmp/mysql.sql
恢复库 mysql -uroot -p123456 mysql < /tmp/mysql.sql
备份表 mysqldump -uroot -p123456 mysql user > /tmp/user.sql
恢复表 mysql -uroot -p123456 mysql < /tmp/user.sql
备份所有库 mysqldump -uroot -p -A >/tmp/123.sql
只备份表结构 mysqldump -uroot -p123456 -d mysql > /tmp/mysql.sql