日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

MySql8.0.19最新版本创建用户分配权限演示,You have an error in your SQL syntax权限分配问题解决方法

發布時間:2025/4/16 数据库 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySql8.0.19最新版本创建用户分配权限演示,You have an error in your SQL syntax权限分配问题解决方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

MySql 8.0.19 權限分配

  • 問題一:You have an error in your SQL syntax ---語法問題
  • 問題二:You are not allowed to create a user with GRANT ---權限問題
  • 問題三:No database selected ---沒選擇數據庫
  • 創建數據庫分配權限演示

問題一:You have an error in your SQL syntax —語法問題

MySql8.0.19 版本分配權限這有了一些改變,不需要后面的identified by '123456a'了

mysql> grant all privileges on sonar_scan.* to 'sonar'@'%' identified by '123456 a'; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ident ified by '123456a'' at line 1

分配權限

mysql> grant all privileges on sonar_scan.* to 'sonar'@'%'; Query OK, 0 rows affected (0.24 sec)

問題二:You are not allowed to create a user with GRANT —權限問題

分配權限,% 代表全域,如果要遠程使用數據庫的話必須分配這個權限。

mysql> grant all privileges on sonar_scan.* to 'sonar'@'%'; Query OK, 0 rows affected (0.24 sec)

如果分配了全域,這個時候再分配本地就會報錯,其實 % 已經包含 localhost 了。

mysql> grant all privileges on sonar_scan.* to 'sonar'@'localhost'; ERROR 1410 (42000): You are not allowed to create a user with GRANT

如果硬要是分配本地的話,要執這么一句就好了。要換回全域,在把 host 改成 % 就好了。

mysql> update user set host='localhost' where user='sonar'; Query OK, 1 row affected (0.53 sec) Rows matched: 1 Changed: 1 Warnings: 0

問題三:No database selected —沒選擇數據庫

用一句 use mysql 就能解決問題了。

mysql> update user set host='localhost' where user='sonar'; ERROR 1046 (3D000): No database selected mysql> use mysql; Database changed mysql> update user set host='localhost' where user='sonar'; Query OK, 1 row affected (0.53 sec) Rows matched: 1 Changed: 1 Warnings: 0

創建數據庫分配權限演示

創建數據庫

mysql> create database sonar_scan default character set utf8 collate utf8_genera l_ci; Query OK, 1 row affected, 2 warnings (0.19 sec)

創建用戶

mysql> create user 'sonar' identified by '123456a'; Query OK, 0 rows affected (0.11 sec)

分配權限

mysql> grant all privileges on sonar_scan.* to 'sonar'@'%'; Query OK, 0 rows affected (0.24 sec)

喜歡的點個贊?吧!

總結

以上是生活随笔為你收集整理的MySql8.0.19最新版本创建用户分配权限演示,You have an error in your SQL syntax权限分配问题解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。