服務器中的表
select
Host
,User
,Select_priv
,Insert_priv
,Update_priv
,Delete_priv
,Create_priv
,Drop_priv
,Reload_priv
,Shutdown_priv
,Process_priv
,File_priv
,Grant_priv
,References_priv
,Index_priv
,Alter_priv
,Show_db_priv
,Super_priv
,Create_tmp_table_priv
,Lock_tables_priv
,Execute_priv
,Repl_slave_priv
,Repl_client_priv
,Create_view_priv
,Show_view_priv
,Create_routine_priv
,Alter_routine_priv
,Create_user_priv
,Event_priv
,Trigger_priv
,Create_tablespace_priv
,ssl_type
,ssl_cipher
,x509_issuer
,x509_subject
,max_questions
,max_updates
,max_connections
,max_user_connections
,plugin
,authentication_string
,password_expired
,password_last_changed
,password_lifetime
,account_locked from user;
查詢mysql全部用戶<--兩種-->
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
SELECT HOST,USER FROM mysql.user;
信息:
117.136.94.236
本機ip:192.168.42.23
39.108.172.95
121.43.18.69
sudo /usr/local/mysql/bin/mysql -uroot -pBF1f8357c50e
BF1f8357c50e</div>
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'BF1f8357c50e' WITH GRANT OPTION;flush privileges;</div>
出現:[emerg] 4613#0: bind() to 0.0.0.0:80 failed (98: Address already in use)錯誤!!!!!
解決方式:
使用命令關閉佔用80端口的程序
sudo fuser -k 80/tcp
進入mysql命令:
mysql -hlocalhost(主機地址) -uroot(用戶名) -p密碼
關閉mysql命令:
mysql退出三種方法:
mysql > exit;
mysql > quit;
mysql > \q;
中止防火牆
sudo systemctl stop firewalld.service
並禁用防火牆服務
sudo systemctl disable firewalld.service
執行後效果:
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
安裝iptables並啓動該服務
#安裝
sudo yum install iptables-services
執行後效果:
complate
#開啓iptables
sudo systemctl enable iptables
sudo systemctl enable ip6tables
執行後效果:
Created symlink from /etc/systemd/system/basic.target.wants/iptables.service to /usr/lib/systemd/system/iptables.service.
Created symlink from /etc/systemd/system/basic.target.wants/ip6tables.service to /usr/lib/systemd/system/ip6tables.service.
#啓動服務
sudo systemctl start iptables
sudo systemctl start ip6tables
查看防火牆狀態
systemctl status firewalld
(dead)未開啓狀態
(running)開啓狀態
開啓防火牆:
systemctl start firewalld
關閉防火牆:
systemctl stop firewalld
{開啓/關閉}防火牆,命令行都沒有效果可經過systemctl status firewalld查看防火牆狀態
Warning: ALREADY_ENABLED: mysql ==》警告:已經啓用:mysql
若用本地sqlyog鏈接服務器上的mysql數據庫則修改:
(1)Linux centos7 將mysql加入防火牆
sudo firewall-cmd --zone=public --permanent --add-service=mysql
效果:
success
(2)重啓防火牆
先關閉防火牆:
systemctl stop firewalld
後開啓防火牆:
systemctl start firewalld
查看防火牆狀態
systemctl status firewalld
效果:=======》以下、、、、、
(3)查詢數據庫使用權限
@1:鏈接數據庫
mysql -uroot(用戶名) -p密碼
@2:拼寫sql語句查詢
select host,user from mysql.user;
效果形似:(注意此時沒有紅色區域的內容)
@3:爲該(root)用戶添加權限(任何ip都能訪問此數據庫===》%)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'BF1f8357c50e' WITH GRANT OPTION;flush privileges;
@4:再次查詢權限
select host,user from mysql.user;
此時效果應爲: