Linux 對mysql遠程連接的授權操作
首先linux連接mysql數據庫
授權: grant all on *.* to 'root'@'%' identified by '123456' with grant option; //允許賬戶root從任何主機連接到所有數據庫(*.*) grant all on test.* to 'user'@'%' identified by '123456' with grant option; //允許賬戶user從任何主機連接到test數據庫(test.*) 釋放遠程授權: revoke all on *.* from 'user'@'%'; //禁止用戶user從任何主機訪問所有數據庫 revoke all on test.* from 'user'@'%'; //禁止用戶user從任何主機訪問test數據庫 flush privileges; //刷新系統授權表
連接不上關閉防火牆
關閉防火牆命令:systemctl stop firewalld.service
開啟防火牆:systemctl start firewalld.service
關閉開機自啟動:systemctl disable firewalld.service
開啟開機啟動:systemctl enable firewalld.service
linux連接mysql數據庫對數據庫的操作的一些基本命令
/usr/local/mysql/bin/mysql -uroot -p //連接mysql數據庫 mysql其他命令: show databases; //顯示數據庫 create database name; //創建數據庫 use databasename; //選擇數據庫 drop database name //直接刪除數據庫,不提醒 show tables; //顯示表 describe tablename; //顯示具體的表結構 select 中加上distinct去除重復字段 mysqladmin drop databasename //刪除數據庫前,有提示。 //顯示當前mysql版本和當前日期 select version(),current_date;