MySQL 8使用密码无法创建新用户 [英] MySQL 8 create new user with password not working

查看:76
本文介绍了MySQL 8使用密码无法创建新用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用MySQL多年了,直到MySQL 5.x版本为止,用于创建新用户的命令如下:

I am using MySQL for several years and the command for the creating the new user till the MySQL 5.x version is as follow:

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';

最近我安装了MySQL8.因此,该命令不起作用.

Recently I installed the MySQL 8. In that, this command is not working.

在触发上述命令时抛出以下错误:

It is throwing following error while firing above command:

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 'password'' at line 1

MySQL 8中的语法是否有任何变化?在MySQL 8中创建新用户命令的正确语法是什么?

Is there any change of syntax in MySQL 8? What is the correct syntax for creating new user command in MySQL 8?

注意:我在MySQL 5.x版本中尝试了这种语法.在那可以正常工作.

Note: I tried this syntax in MySQL 5.x versions. It is working correctly in that.

推荐答案

尝试一下:

use mysql;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'username'@'localhost';
flush privileges;

这篇关于MySQL 8使用密码无法创建新用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆