mysql 常用sql语句
- 权限
-
撤销权限
revoke all on *.* from 'root'@'192.168.0.197' ; - 撤销权限
revoke all on *.* from 'xx_db' @'%'; -
给指定用户赋予指定数据库select的权限
grant select ON xx_db TO 'user_xx' @'%' IDENTIFIED BY "password";
给指定用户赋予指定数据库所有的权限
grant all privileges on xx_db.* to 'user_xxb' @'%' identified by "password";
给所有用户赋予指定数据库所有权限
grant select on *.* to 'xx_db' @'%' identified by "password";
给所有用户赋予所有权限(远程访问,不限制在本机访问)
grant all privileges on *.* to 'user_xx' @'%' identified by "password";
赋予grant的权限
grant all privileges on *.* to 'user_xx' @'%' WITH GRANT OPTION给指定用户赋予所有数据库的权限
grant select on xx_db to 'user_xx' @'%' identified by "password";
- 备份
备份整库:
mysqldump -h192.168.XX.XX -uroot -p --databases DB > DB_bak_`date +%y%m%d_%H:%M:%S`.sql
- 对比两个数据库的表以及记录是否一致:
select * from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = '_db' order by create_time desc;