mysql測試部分總結

一、創建數據庫查看:
例如:在網站創建test_db2、test_db1 ,登錄mysql命令行查看:
 show databases;

二、創建用戶沒有授權數據庫查看: show grants for testjz; (沒有授權16條記錄)


三、創建用戶授權N個數據庫查看: show grants for testjz; (授權16+N條記錄) 

注:創建賬號登錄後查看只有information_schema 、mysql 、performance_schema三個系統庫和授權的數據庫

[root@4xvt6 ~]# mysql  -utestjz -pJizheng1987
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test_db            |
| test_db1           |
+--------------------+
5 rows in set (0.00 sec)

四、賬號密碼修改

[root@4xvt6 ~]# mysql  -utestjz -pJizheng1987
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'testjz'@'localhost' (using password: YES)

[root@4xvt6 ~]# mysql  -utestjz -pJizheng2017

五、添加白名單

說明:主備虛機互相添加白名單訪問策略: 主備ip分別爲10.0.48.49、10.0.49.181 
         用戶添加的ip白名單爲124.127.244.1
         執行如下命令 iptables -nvL 查看白名單策略

[root@4xvt7 ~]# iptables -nvL
Chain INPUT (policy ACCEPT 82 packets, 8765 bytes)
 pkts bytes target     prot opt in     out     source               destination         
   45  8243 ACCEPT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
    0     0 ACCEPT     icmp --  eth0   *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
    6   468 IP_ACCEPT  all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           
    0     0 REJECT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 REJECT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT 54 packets, 9861 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain IP_ACCEPT (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  *      *       124.127.244.1        0.0.0.0/0           
    0     0 ACCEPT     all  --  *      *       10.0.48.49           0.0.0.0/0         
  
    6   468 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0   

[root@4xvt6 ~]# iptables -nvL
Chain INPUT (policy ACCEPT 193 packets, 14644 bytes)
 pkts bytes target     prot opt in     out     source               destination         
   45  2893 ACCEPT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
    0     0 ACCEPT     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
    0     0 ACCEPT     icmp --  eth0   *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     icmp --  eth1   *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
    7   528 IP_ACCEPT  all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           
    6   468 IP_ACCEPT  all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           
    0     0 REJECT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 
    0     0 REJECT     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 REJECT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 
    0     0 REJECT     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT 99 packets, 14524 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain IP_ACCEPT (2 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  *      *       124.127.244.1        0.0.0.0/0           
    1    60 ACCEPT     all  --  *      *       10.0.49.181          0.0.0.0/0    
       
   12   936 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0   


六、查看主備虛機

1.查看當前虛機是否是主、從虛機( read_only爲ON爲從虛機;OFF爲主虛機
mysql> show global variables like 'read_only';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| read_only     | ON    |
+---------------+-------+
1 row in set (0.00 sec)


mysql> show global variables like 'read_only';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| read_only     | OFF   |
+---------------+-------+
1 row in set (0.00 sec)


2.知道root密碼的情況下查看(返回數據爲空則爲主虛機)

mysql> show slave status;
Empty set (0.00 sec)

mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.0.48.49
                  Master_User: repl
                  Master_Port: 3306

        
注:Master_Host: 爲主虛機ip  Master_User爲主從同步的賬號   Master_Port 主虛機的端口


七、登錄pma
創建一臺windows的雲主機
1.通過內網驗證:輸入http://內網:8080/phpmyadmin  提示輸入用戶名和密碼

輸入成功後如下所示



八、備份與恢復

1.備份的文件存儲在存儲服務器(10.12.29.53)的目錄下
規則:  /smart/database/backup/客戶id/數據庫實例uuid/data/logical_backup
/smart/database/backup/1100003/8299337/data/logical_backup

[root@TStorage03 logical_backup]# pwd
/smart/database/backup/1100003/8299337/data/logical_backup
[root@TStorage03 logical_backup]# ll
total 20
-rw-r--r--. 1 root root     0 Dec  4 20:18 d121111_backup_20171204_201843.log
-rw-r--r--. 1 root root     0 Dec  4 20:27 d121111_recovery_20171204_202720.log
-rw-r--r--. 1 root root 20480 Dec  4 20:48 ins125186514_data_20171204_204803.tar
-rw-r--r--. 1 root root     0 Dec  4 20:18 test_db1_backup_20171204_201843.log
-rw-r--r--. 1 root root     0 Dec  4 20:48 test_db1_backup_20171204_204803.log
-rw-r--r--. 1 root root     0 Dec  4 20:27 test_db1_recovery_20171204_202720.log
-rw-r--r--. 1 root root     0 Dec  4 20:18 test_db2_backup_20171204_201843.log
-rw-r--r--. 1 root root     0 Dec  4 20:48 test_db2_backup_20171204_204803.log
-rw-r--r--. 1 root root     0 Dec  4 20:27 test_db2_recovery_20171204_202720.log
-rw-r--r--. 1 root root     0 Dec  4 20:18 test_db_backup_20171204_201843.log
-rw-r--r--. 1 root root     0 Dec  4 20:48 test_db_backup_20171204_204803.log
-rw-r--r--. 1 root root     0 Dec  4 20:27 test_db_recovery_20171204_202720.log


2、恢復:將數據庫中創建的表中數據刪除部分,測試恢復是否正常
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章