MySql8.0.19最新版本创建用户分配权限演示,You have an error in your SQL syntax权限分配问题解决方法
时间:2022-07-25
本文章向大家介绍MySql8.0.19最新版本创建用户分配权限演示,You have an error in your SQL syntax权限分配问题解决方法,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
问题一: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)
- MySQL 教程
- MySQL 安装
- MySQL 管理与配置
- MySQL PHP 语法
- MySQL 连接
- MySQL 创建数据库
- MySQL 删除数据库
- MySQL 选择数据库
- MySQL 数据类型
- MySQL 创建数据表
- MySQL 删除数据表
- MySQL 插入数据
- MySQL 查询数据
- MySQL where 子句
- MySQL UPDATE 查询
- MySQL DELETE 语句
- MySQL LIKE 子句
- mysql order by
- Mysql Join的使用
- MySQL NULL 值处理
- MySQL 正则表达式
- MySQL 事务
- MySQL ALTER命令
- MySQL 索引
- MySQL 临时表
- MySQL 复制表
- 查看MySQL 元数据
- MySQL 序列 AUTO_INCREMENT
- MySQL 处理重复数据
- MySQL 及 SQL 注入
- MySQL 导出数据
- MySQL 导入数据
- MYSQL 函数大全
- MySQL Group By 实例讲解
- MySQL Max()函数实例讲解
- mysql count函数实例
- MYSQL UNION和UNION ALL实例
- MySQL IN 用法
- MySQL between and 实例讲解