mysql中grant all privileges on怎麼賦給使用者遠端權限
mysql grant all privileges on賦給使用者遠端權限
mysql中grant all privileges on賦給使用者遠端權限
改表法。
當你的帳號不允許從遠端登陸,只能在localhost連線時。這時候只要在mysql伺服器上,更改mysql 資料庫裡的user 表裡的host 項,從localhost"改成%即可實現用戶遠端登入
在安裝mysql的機器上運行:
1. mysql -u root -p
2. select host,user from user where user='root';
3. update user set host = '%' 其中 user= 'root' and host='localhost';
4. select host, user from user where user='root';
授權法
[root@aaa-server ~]# mysql -u root -p MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by '123' with grant option; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit Bye
授權法。
例如,你想要user使用mypwd從任何主機連接到mysql伺服器的話。
在安裝mysql的機器上運行:
1. GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'mypwd' WITH GRANT OPTION; 2.FLUSH PRIVILEGES; 模板: grant all privileges on 库名.表名 to '用户名'@'IP地址' identified by '密码' with grant option; flush privileges;
如果你想允許用戶user從ip為192.168.1.4的主機連接到mysql伺服器,並使用mypwd作為密碼
在安裝mysql的機器上運行:
GRANT ALL PRIVILEGES ON *.* TO 'user'@'192.168.1.3' IDENTIFIED BY 'mypwd' WITH GRANT OPTION; FLUSH PRIVILEGES;
注意授權後必須FLUSH PRIVILEGES;否則無法立即生效。
高版本資料庫無法依照grant all privileges on *.* to "root"@"%" identified by "xxxx";去修改使用者權限
mysql> SELECT @@VERSION; +-----------+ | @@VERSION | +-----------+ | 8.0.14 | +-----------+ 1 row in set (0.00 sec)
高版本修改使用者權限方法:
# 先创建远程用户,再授权 mysql> create user 'root'@'%' identified by 'password'; Query OK, 0 rows affected (0.03 sec) mysql> grant all privileges on *.* to 'root'@'%' with grant option; Query OK, 0 rows affected (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
再次查看發現有了root %
mysql> select User,Host from user; +------------------+-----------+ | User | Host | +------------------+-----------+ | root | % | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +------------------+-----------+ 5 rows in set (0.00 sec) ————————————————
mysql授權語句說明grant all privileges、建立使用者、刪除使用者
mysql的賦權語句:
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
all privileges ==》 表示所有的權限,增刪改核權限全部都有了
- ##*.* == ;的資料庫下面所有的表
- root@% ==》 所有資料庫下面所有的表,所有的權限,全部都給root用戶 % 表示root用戶可以在任何機器上面進行連線登入
- The password used for remote login connection is "123456".
刷新權限清單:flush privileges#
CREATE DATABASE 数据库名; CREATE USER '用户名'@'%' IDENTIFIED BY '密码'; GRANT all privileges ON 数据库名.* to '用户名'@'%' identified by '密码' WITH GRANT OPTION; flush privileges;
drop user ‘jack'@'%';
以上是mysql中grant all privileges on怎麼賦給使用者遠端權限的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

如何修復 MySQL 8.4 上的 mysql_native_password 未載入錯誤
