定制开发小程序ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your

 定制开发小程序遇到这个报错?定制开发小程序不知道怎么办?要哭了?

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 '("123456") where user='root'' at line 1

 

MySQL grant的SQL命令其实在5.X之后就已经被弃用了


首先,你先检查一下你的MySQL版本, 大多数执行报错的MySQL版本是8.0的。


1.先用MySQL 8.0试一下

mysql> grant all privileges on test.* to test@'%' identified by '123456';  

这里报错

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 'identified by '123456'' at line 1

2.再用MySQL 5.7试一下

  1. mysql> grant all privileges on test.* to test@'%' identified by '123456';    
  2. Query OK, 0 rows affected, 1 warning (0.08 sec)
  3. mysql> flush privileges;

正确的执行赋权


那么在MySQL8.0版本及以后,我们如何正确执行grant呢?

先创建用户,再赋予授权。

mysql> create user test@'localhost' identified by '123456';


Query OK, 0 rows affected (0.10 sec)

mysql> grant all privileges on test.* to test@'localhost';


Query OK, 0 rows affected (0.17 sec)

mysql> flush privileges;


Query OK, 0 rows affected (0.18 sec)

这个方法也适用MySQL5.7版本,所以建议大家以后使用这种方式赋权,一键建用户加赋权官方已经弃用了。
 

 

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发