今天在搭建主從後出現了主庫system帳號丟失INSERT權限的狀況,記錄以下mysql
主庫:
system帳號權限同root權限,而且mysql庫已經刪除sql
從庫:
mysql庫存在,無system帳號oop
主從同步搭建完成後,start slave開啓同步,返回主庫測試,發現能夠建表,可是不能插入數據,查看system用戶權限以下
mysql> select * from user where user='system'\G;
*************************** 1. row ***************************
Host: localhost
User: system
Password: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
Select_priv: Y
Insert_priv: N
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: Y
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Create_tablespace_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string:
password_expired: N
1 row in set (0.00 sec)測試
能夠看到system具備更新的權限,遂作以下處理:
mysql> update user set Insert_priv='Y' where user='system';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0spa
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)ip
保險起見,重啓mysql
[root@HadoopDEV1 3306]# ./mysql stop
Mysqldstoping......
[1]+ 完成 mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-tables 2>&1 > /dev/null
[root@HadoopDEV1 3306]# ./mysql start
Mysqldstarting......
[root@HadoopDEV1 3306]# mysql -usystem -p -S /data/3306/data/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.15-log MySQL Community Server (GPL)ssl
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.ci
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.input
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.同步
再次查看system用戶權限
mysql> select * from mysql.user where user='system'\G;
*************************** 1. row ***************************
Host: localhost
User: system
Password: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: Y
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Create_tablespace_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string:
password_expired: N
1 row in set (0.00 sec)
插入數據測試:
mysql> select * from t;
Empty set (0.00 sec)
mysql> insert into t values(2);
Query OK, 1 row affected (0.01 sec)
mysql> select * from t;
+------+
| id |
+------+
| 2 |
+------+
1 row in set (0.00 sec)
測試插入正常,對於具體緣由尚不得知