MySql8.0.19最新版本创建用户分配权限演示,You have an error in your SQL syntax权限分配问题解决方法
生活随笔
收集整理的這篇文章主要介紹了
MySql8.0.19最新版本创建用户分配权限演示,You have an error in your SQL syntax权限分配问题解决方法
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
MySql 8.0.19 權(quán)限分配
- 問題一:You have an error in your SQL syntax ---語法問題
- 問題二:You are not allowed to create a user with GRANT ---權(quán)限問題
- 問題三:No database selected ---沒選擇數(shù)據(jù)庫
- 創(chuàng)建數(shù)據(jù)庫分配權(quán)限演示
問題一:You have an error in your SQL syntax —語法問題
MySql8.0.19 版本分配權(quán)限這有了一些改變,不需要后面的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分配權(quán)限
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 —權(quán)限問題
分配權(quán)限,% 代表全域,如果要遠(yuǎn)程使用數(shù)據(jù)庫的話必須分配這個(gè)權(quán)限。
mysql> grant all privileges on sonar_scan.* to 'sonar'@'%'; Query OK, 0 rows affected (0.24 sec)如果分配了全域,這個(gè)時(shí)候再分配本地就會(huì)報(bào)錯(cuò),其實(shí) % 已經(jīng)包含 localhost 了。
mysql> grant all privileges on sonar_scan.* to 'sonar'@'localhost'; ERROR 1410 (42000): You are not allowed to create a user with GRANT如果硬要是分配本地的話,要執(zhí)這么一句就好了。要換回全域,在把 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 —沒選擇數(shù)據(jù)庫
用一句 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創(chuàng)建數(shù)據(jù)庫分配權(quán)限演示
創(chuàng)建數(shù)據(jù)庫
mysql> create database sonar_scan default character set utf8 collate utf8_genera l_ci; Query OK, 1 row affected, 2 warnings (0.19 sec)創(chuàng)建用戶
mysql> create user 'sonar' identified by '123456a'; Query OK, 0 rows affected (0.11 sec)分配權(quán)限
mysql> grant all privileges on sonar_scan.* to 'sonar'@'%'; Query OK, 0 rows affected (0.24 sec)喜歡的點(diǎn)個(gè)贊?吧!
總結(jié)
以上是生活随笔為你收集整理的MySql8.0.19最新版本创建用户分配权限演示,You have an error in your SQL syntax权限分配问题解决方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 不支持图形化界面的Linux系统如何显示
- 下一篇: 白盒测试工具 - sonar报告常见示例