mysql 添加远程连接用户 删除root的远程连接 远程导出 远程备份 只读用户

删除root的远程连接

mysql>use mysql;

mysql>delete from user where user='root' and host='%';

mysql>flush privileges;

 

添加所有权限远程连接用户[root权限]

mysql>use mysql;

mysql> insert into user (host,user,password) values ('%','newuser',password('123456'));
Query OK, 1 row affected, 3 warnings (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on *.* to newuser@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql>

 

添加只读权限的用户

use mysql;
insert into user (host,user,password) values ('%','zys',password('zys123456'));
flush privileges;
grant SELECT on admin.* to zys@'%'; #如果是所有库,那么就将admin.* 改为*.*
flush privileges;

 

mysql数据备份导出命令

mysqldump -uroot -p123456 --single-transaction game>game.sql  #导出备份

mysqldump -h183.xx.xx.xx -uusername -ppwd --single-transaction passport>passport.sql #远程导出备份

mysql -u root -p database < xx.sql  #导入


分享到: 微信 更多