root@MySQL-01 15:42: [(none)]> use mysql Database changed root@MySQL-01 15:42: [mysql]> create table user_1 like user; Query OK, 0 rows affected (0.01 sec)
root@MySQL-01 15:42: [mysql]> insert into user_1 select * from user; Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0
root@MySQL-01 15:42: [mysql]> select user,host,authentication_string from mysql.user; +------+-----------+-------------------------------------------+ | user | host | authentication_string | +------+-----------+-------------------------------------------+ | root | localhost | *D4DF57DFB7019B3D8C4294CC413AF1D650A275E4 | | root | 127.0.0.1 | *D4DF57DFB7019B3D8C4294CC413AF1D650A275E4 | | root | ::1 | *D4DF57DFB7019B3D8C4294CC413AF1D650A275E4 | +------+-----------+-------------------------------------------+ 3 rows in set (0.00 sec)
root@MySQL-01 15:42: [mysql]> select user,host,authentication_string from mysql.user_1; +------+-----------+-------------------------------------------+ | user | host | authentication_string | +------+-----------+-------------------------------------------+ | root | localhost | *D4DF57DFB7019B3D8C4294CC413AF1D650A275E4 | | root | 127.0.0.1 | *D4DF57DFB7019B3D8C4294CC413AF1D650A275E4 | | root | ::1 | *D4DF57DFB7019B3D8C4294CC413AF1D650A275E4 | +------+-----------+-------------------------------------------+ 3 rows in set (0.00 sec)
root@MySQL-01 15:42: [mysql]> desc mysql.user_1; +------------------------+-----------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+-----------------------------------+------+-----+---------+-------+ | Host | char(60) | NO | PRI | | | | User | char(16) | NO | PRI | | | | Password | char(41) | NO | | | | | Select_priv | enum('N','Y') | NO | | N | | | Insert_priv | enum('N','Y') | NO | | N | | | Update_priv | enum('N','Y') | NO | | N | | | Delete_priv | enum('N','Y') | NO | | N | | | Create_priv | enum('N','Y') | NO | | N | | | Drop_priv | enum('N','Y') | NO | | N | | | Reload_priv | enum('N','Y') | NO | | N | | | Shutdown_priv | enum('N','Y') | NO | | N | | | Process_priv | enum('N','Y') | NO | | N | | | File_priv | enum('N','Y') | NO | | N | | | Grant_priv | enum('N','Y') | NO | | N | | | References_priv | enum('N','Y') | NO | | N | | | Index_priv | enum('N','Y') | NO | | N | | | Alter_priv | enum('N','Y') | NO | | N | | | Show_db_priv | enum('N','Y') | NO | | N | | | Super_priv | enum('N','Y') | NO | | N | | | Create_tmp_table_priv | enum('N','Y') | NO | | N | | | Lock_tables_priv | enum('N','Y') | NO | | N | | | Execute_priv | enum('N','Y') | NO | | N | | | Repl_slave_priv | enum('N','Y') | NO | | N | | | Repl_client_priv | enum('N','Y') | NO | | N | | | Create_view_priv | enum('N','Y') | NO | | N | | | Show_view_priv | enum('N','Y') | NO | | N | | | Create_routine_priv | enum('N','Y') | NO | | N | | | Alter_routine_priv | enum('N','Y') | NO | | N | | | Create_user_priv | enum('N','Y') | NO | | N | | | Event_priv | enum('N','Y') | NO | | N | | | Trigger_priv | enum('N','Y') | NO | | N | | | Create_tablespace_priv | enum('N','Y') | NO | | N | | | ssl_type | enum('','ANY','X509','SPECIFIED') | NO | | | | | ssl_cipher | blob | NO | | NULL | | | x509_issuer | blob | NO | | NULL | | | x509_subject | blob | NO | | NULL | | | max_questions | int(11) unsigned | NO | | 0 | | | max_updates | int(11) unsigned | NO | | 0 | | | max_connections | int(11) unsigned | NO | | 0 | | | max_user_connections | int(11) unsigned | NO | | 0 | | | plugin | char(64) | YES | | | | | authentication_string | text | YES | | NULL | | +------------------------+-----------------------------------+------+-----+---------+-------+ 42 rows in set (0.00 sec)
root@MySQL-01 15:47: [mysql]> delete from mysql.user_1 where user='root'; Query OK, 3 rows affected (0.00 sec)
root@MySQL-01 15:51: [mysql]> insert into mysql.user_1 values ('%','root', '', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', '', '', '', '', 0, 0, 0, 0, '', password('123')); Query OK, 1 row affected, 1 warning (0.00 sec)
root@MySQL-01 15:52: [mysql]> insert into mysql.user_1 values ('%','joowingbuz', '', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', '', '', '', '', 0, 0, 0, 0, '', password('123')); Query OK, 1 row affected, 1 warning (0.00 sec)
root@MySQL-01 15:52: [mysql]> insert into mysql.user_1 values ('%','ottersync', '', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', '', '', '', '', 0, 0, 0, 0, '', password('123')); Query OK, 1 row affected, 1 warning (0.00 sec)
root@MySQL-01 15:52: [mysql]> insert into mysql.user_1 values ('%','syncdw', '', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', '', '', '', '', 0, 0, 0, 0, '', password('123'));
root@MySQL-01 15:52: [mysql]> insert into mysql.user_1 values ('%','datasis', '', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', '', '', '', '', 0, 0, 0, 0, '', password('123')); Query OK, 1 row affected, 1 warning (0.00 sec)
root@MySQL-01 15:52: [mysql]> insert into mysql.user_1 values ('%','joowingv', '', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', '', '', '', '', 0, 0, 0, 0, '', password('123')); Query OK, 1 row affected, 1 warning (0.01 sec)
root@MySQL-01 15:52: [mysql]> insert into mysql.user_1 values ('%','datadev', '', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', '', '', '', '', 0, 0, 0, 0, '', password('123')); Query OK, 1 row affected, 1 warning (0.00 sec)
root@MySQL-01 15:52: [mysql]> insert into mysql.user_1 values ('%','readonly', '', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', '', '', '', '', 0, 0, 0, 0, '', password('123')); Query OK, 1 row affected, 1 warning (0.00 sec)
root@MySQL-01 15:52: [mysql]> select user,host,authentication_string from mysql.user; +------+-----------+-------------------------------------------+ | user | host | authentication_string | +------+-----------+-------------------------------------------+ | root | localhost | *D4DF57DFB7019B3D8C4294CC413AF1D650A275E4 | | root | 127.0.0.1 | *D4DF57DFB7019B3D8C4294CC413AF1D650A275E4 | | root | ::1 | *D4DF57DFB7019B3D8C4294CC413AF1D650A275E4 | +------+-----------+-------------------------------------------+ 3 rows in set (0.00 sec)
root@MySQL-01 15:52: [mysql]> select user,host,authentication_string from mysql.user_1; +------------+------+-------------------------------------------+ | user | host | authentication_string | +------------+------+-------------------------------------------+ | ottersync | % | *9443FA914A2D69FE8832F8294E7422CC1B02A492 | | joowingbuz | % | *DFFDA1CA6135E355EF468AB13A465BB5D4FE2B11 | | root | % | *89BE852E4EECFD217F0C5463FB30AD25BD0751E0 | | syncdw | % | *3DD7B4B4F6EE968FF3452B607BDEE6294B6A425A | | datasis | % | *011D511C71990F832C531A0F9CFB34CF7BB4E485 | | joowingv | % | *56B364074270DF7F6D670A6B4F5A4AD13322397A | | datadev | % | *D3D73E0F6BFC3159B024EF31484B6F9CC2963C5B | | readonly | % | *E2BA196C0C7F409990FDB3FAB5F9C7CE95F7C449 | +------------+------+-------------------------------------------+ 8 rows in set (0.00 sec)
root@joowing-server-06:~# /data/mysql/support-files/mysql.server stop Shutting down MySQL ...... *
root@joowing-server-06:~# cd /data/xtrabackup_data/ root@joowing-server-06:/data/xtrabackup_data# cd mysql root@joowing-server-06:/data/xtrabackup_data/mysql# ll user* -rw-r----- 1 mysql mysql 10630 8月 14 15:42 user_1.frm -rw-r----- 1 mysql mysql 744 8月 14 15:52 user_1.MYD -rw-r----- 1 mysql mysql 2048 8月 14 15:53 user_1.MYI -rw-r----- 1 mysql mysql 10630 8月 9 20:14 user.frm -rw-r----- 1 mysql mysql 98304 8月 9 20:14 user.ibd -rw-r--r-- 1 mysql mysql 328 8月 9 20:14 user.MYD -rw-r--r-- 1 mysql mysql 2048 8月 9 20:14 user.MYI -rw-r----- 1 mysql mysql 3569 8月 9 20:14 user.TRG -rw-r----- 1 mysql mysql 3982 8月 9 20:14 user_view.frm root@joowing-server-06:/data/xtrabackup_data/mysql# mv user.frm user.ibd user.MYD user.MYI user.TRG /data root@joowing-server-06:/data/xtrabackup_data/mysql# ll user* -rw-r----- 1 mysql mysql 10630 8月 14 15:42 user_1.frm -rw-r----- 1 mysql mysql 744 8月 14 15:52 user_1.MYD -rw-r----- 1 mysql mysql 2048 8月 14 15:53 user_1.MYI -rw-r----- 1 mysql mysql 3982 8月 9 20:14 user_view.frm root@joowing-server-06:/data/xtrabackup_data/mysql# mv user_1.frm user.frm root@joowing-server-06:/data/xtrabackup_data/mysql# mv user_1.MYI user.MYI root@joowing-server-06:/data/xtrabackup_data/mysql# mv user_1.MYD user.MYD root@joowing-server-06:/data/xtrabackup_data/mysql# ll user* -rw-r----- 1 mysql mysql 10630 8月 14 15:42 user.frm -rw-r----- 1 mysql mysql 744 8月 14 15:52 user.MYD -rw-r----- 1 mysql mysql 2048 8月 14 15:53 user.MYI -rw-r----- 1 mysql mysql 3982 8月 9 20:14 user_view.frm root@joowing-server-06:/data/xtrabackup_data/mysql# /data/mysql/support-files/mysql.server start Starting MySQL ...... *
root@joowing-server-06:/data/xtrabackup_data/mysql# mysql -uroot -p'123' mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.20-log MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root@MySQL-01 15:55: [(none)]> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: rm-uf6f05k2rg95s23bp.mysql.rds.aliyuncs.com Master_User: idc_slave Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.001641 Read_Master_Log_Pos: 447207506 Relay_Log_File: joowing-server-06-relay-bin.000225 Relay_Log_Pos: 35529076 Relay_Master_Log_File: mysql-bin.001641 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: mysql.%,sys.%,information_schema.% Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 447207506 Relay_Log_Space: 35529295 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1095052097 Master_UUID: b3e1de69-5daa-11e8-bed2-7cd30ab8a9fc Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: b3e1de69-5daa-11e8-bed2-7cd30ab8a9fc:97478646-97483368 Executed_Gtid_Set: b3e1de69-5daa-11e8-bed2-7cd30ab8a9fc:1-97483368, c39ecf19-5daa-11e8-aa9c-7cd30ac4764a:1-178658794, c69289d7-9bc9-11e8-b922-44a842431b62:1-12 Auto_Position: 1 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 1 row in set (0.00 sec)
ERROR: No query specified
# 验证只读账号 mysql -uroot -p'123' -e "create database dbzyadmin;" mysql -ujoowingbuz -p'123' -e "create database dbzyadmin;" mysql -uottersync -p'123' -e "create database dbzyadmin;" mysql -usyncdw -p'123' -e "create database dbzyadmin;" mysql -udatasis -p'123' -e "create database dbzyadmin;" mysql -ujoowingv -p'123' -e "create database dbzyadmin;" mysql -udatadev -p'123' -e "create database dbzyadmin;" mysql -ureadonly -p'123' -e "create database dbzyadmin;"
# 只读账号无法执行写操作,验证成功 mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1044 (42000) at line 1: Access denied for user 'readonly'@'%' to database 'dbzyadmin'
|