mysql 5 7開啟遠端連線

2021-09-05 23:30:51 字數 2147 閱讀 8920

1、首先到mysql5.7的安裝目錄下,進入bin目錄,然後按住shift滑鼠右鍵,選擇在此處開啟命令視窗

2、登入mysql,輸入mysql  -uroot -p

3、按回車鍵,輸入密碼

4、切換到mysql資料庫,輸入命令use mysql;

5、開啟遠端連線,輸入命令grant all privileges on *.* to 'root'@'%' identified by '密碼' with grant option;

6、重新整理許可權,命令為:flush privileges;

7、重啟mysql服務

create user 'username'@'host' identified by 'password';
create user 'dog'@'localhost' identified by '123456';

create user 'pig'@'192.168.1.101' identified by '123456';

create user 'pig'@'%' identified by '123456';

create user 'pig'@'%' identified by '';

create user 'pig'@'%';

grant privileges on databasename.tablename to 'username'@'host';
grant select, insert on test.user to 'pig'@'%';

grant all on *.* to 'pig'@'%';

grant all on maindataplus.* to 'pig'@'%';

用以上命令授權的使用者不能給其它使用者授權,如果想讓該使用者可以授權,用以下命令:

grant privileges on databasename.tablename to 'username'@'host' with grant option;
set password for 'username'@'host' = password('newpassword');
如果是當前登陸使用者用:

set password = password("newpassword");
set password for 'pig'@'%' = password("123456");
revoke privilege on databasename.tablename from 'username'@'host';
privilege, databasename, tablename:同授權部分

revoke select on *.* from 'pig'@'%';
假如你在給使用者'pig'@'%'授權的時候是這樣的(或類似的):grant select on test.user to 'pig'@'%',則在使用revoke select on *.* from 'pig'@'%';命令並不能撤銷該使用者對test資料庫中user表的select操作。相反,如果授權使用的是grant select on *.* to 'pig'@'%';revoke select on test.user from 'pig'@'%';命令也不能撤銷該使用者對test資料庫中user表的select許可權。

具體資訊可以用命令show grants for 'pig'@'%';檢視。

drop user 'username'@'host';
最後一步就是重新整理許可權:

flush privileges;

Mysql 5 7 開啟遠端連線

centos系統安裝好mysql後,預設情況下不支援使用者通過非本機連線上資料庫伺服器,下面是解決方法 1 在控制台執行 mysql uroot p系統提示輸入資料庫root使用者的密碼,輸入完成後即進入mysql控制台 2 選擇資料庫 use mysql 開啟遠端連線 root 使用者名稱 所有人...

Mysql 5 7 開啟遠端連線

在ubuntu14.04上安裝好mysql5.7之後,本地可以連線mysql伺服器。遠端就不行。注釋掉在 etc mysql mysql.conf.d mysqld.cnf裡面的bind address 127.0.0.1 by default we only accept connections ...

設定mysql5 7遠端連線

在ubuntu14.04上安裝好mysql5.7之後,本地可以連線mysql伺服器。遠端就不行。注釋掉在 etc mysql mysql.conf.d mysqld.cnf裡面的bind address 127.0.0.1 by default we only accept connections ...