当前位置:Gxlcms > 数据库问题 > 数据库授权操作

数据库授权操作

时间:2021-07-01 10:21:17 帮助过:5人阅读

设置其他主机能使用 root 登陆数据库

Mysql>GRANT ALL PRIVILEGES ON * . * TO ‘root‘@‘%‘IDENTIFIED BY ‘password’

设置 user 账户能从 10.10.0.1 服务器登陆本机,且拥有所有权限

Mysql>grant all on *.* to user@10.10.0.1 indentified by ‘password’

user 账户只有备份权限

Mysql>grant replication slave on *.* to user@10.10.0.1 indentified by ‘password’

使添加的账号生效:FLUSH PRIVILEGES;

 

Flush logs; 增加一个最新的 bin-log 日志

Truncate  tables;   清空当前表中的所有数据

Reset master;清空所有的 bin-log 日志

进入二进制日志目录,输入下面语句可查看二进制日志:

mysqlbinlog –no-defaults  mysql-bin.000001 | more

若编译安装的 Mysql,选择 mysql 安装目录下执行 Mysql/bin/mysqlbinlog 

 

数据恢复

Mysql/bin/mysqlbinlog –no-defaults  mysql-bin.000001 |mysql –u –root –p(password) (可选 database)

例如通过 Bin-log 日志恢复 position 段 100 到 500 的数据:

1、先查看 position 段中日志,确实是否需要恢复

mysqlbinlog –no-defaults mysql-bin.000002 –start-position=”100”–stop-position=”500” |more

注意 position100 可能不会恢复。因为执行语句在 Position 日志之上。

–start-position 和 –stop-position 可选择一个执行。无需同时存在。

Btw:时间段恢复参数为:–stop-date= “2014-01-01 12:00:00” 、

–start-date = “2014-01-01 12:00:00”

数据库授权操作

标签:

人气教程排行