GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON bankaccount.* TO custom@localhost IDENTIFIED BY 'stupid';
GRANT all privileges ON *.* TO root@'172.16.4.44' IDENTIFIED BY '123456';
调整
mysql>use mysql
删除用于本机匿名连接的空密码帐号
mysql>delete from user where user="";
更改root密码
mysql>update user set Password=password('newpassword') where User='root';
mysql>flush privileges;
授权新用户
mysql>grant all privileges on DB.* to user@'172.22.5.%' identified by '123456';
移除用户
revoke all on *.* from dba@localhost;
二 主从配置
保证主库和从库的server-id不能一样
1) 主库
mysql > GRANT REPLICATION SLAVE ON *.* TO repl@'172.22.5.%' IDENTIFIED BY '123456';
mysql > FLUSH TABLES WITH READ LOCK
dump一份数据库的sql文件,完成后。
mysql >show master status;
+------------------+-----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+-----------+--------------+------------------+
| mysql-bin.000001 | 106 | | |
+------------------+-----------+--------------+------------------+
记录一下status文件
mysql> UNLOCK TABLES;