mysql 添加遠程訪問


第一種:mysql 5.0(兩種方式)

一、

在命令窗口輸入,mysql -u root -p  回車,並輸入密碼

執行 use mysql 

執行下面句子,查看權限,root默認權限為localhost

select user,host from user;

更改root權限為%

update user set host = '%' where user = 'root';

刷新

flush privileges;

二、

在命令窗口輸入,mysql -u root -p  回車,並輸入密碼

執行 use mysql 

設置test為賬戶,密碼為:ceshipwd,權限為%,所有人

grant all on *.*  to 'test'@'%' identified by 'ceshipwd';

如果權限不設置為所有人,可設定固定訪問IP如下:

grant all on *.*  to 'test'@'111.111.111.111' identified by 'ceshipwd';

最后,刷新

flush privileges;

 

第一種:mysql 8.0以上(兩種方式)

一、

在命令窗口輸入,mysql -u root -p  回車,並輸入密碼

執行 use mysql 

執行下面句子,查看權限,root默認權限為localhost

select user,host from user;

更改root權限為%

update user set host = '%' where user = 'root';

刷新

flush privileges;

二、

在命令窗口輸入,mysql -u root -p  回車,並輸入密碼

執行 use mysql 

設置test為賬戶,密碼為:ceshipwd,權限為%,所有人

先建立賬號:

create user 'test'@'%' identified with mysql_native_password by 'ceshipwd';

再添加賬號權限

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

如果權限不設置為所有人,可設定固定訪問IP如下:

grant all on *.*  to 'test'@'111.111.111.111';

最后,刷新

flush privileges;

三、

各版本修改密碼的格式:

mysql5.0格式如下:

本地可以訪問

alter user 'ceshi'@'localhost' identified   by 'ceshipw';

所有都可以訪問

alter user 'ceshi'@'%' identified   by 'ceshipw';

mysql8.0以上格式如下:

本地可以訪問

alter user 'ceshi'@'localhost' identified with mysql_native_password  by 'ceshipw';

所有都可以訪問

alter user 'ceshi'@'%' identified  with mysql_native_password by 'ceshipw';

 

*使用navicat連接mysql8.0數據庫時,提示1251-client does not support authentication protocol requested by server;consider upgrading mysql client 解決辦法:

進入數據庫,更新一下認證格式
user mysql;
#下面方式是修改密碼的格式,即可正常訪問 alter user 'ceshi'@'%' identified with mysql_native_password by 'ceshipw'; flush privileges;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM