免费mysql服务器_mysql初始化失败

2022-09-22 20:03:31 浏览数 (2)

大家好,又见面了,我是你们的朋友全栈君。

1.在mysql 数据库里面想再建立一个用户,可是提示错误?

​在mysql命令行里面,想用“create

user”命令建立一个名为“developer”,密码为“123456”的mysql用户。

语句:create user ‘developer’@’localhost’ identified by

‘123456’;

可是执行之后提示:

ERROR 1396:Operation CREATE USER failed for

‘developer’@’localhost’

这是为什么啊?如何解决啊?

解:::你的 ‘developer’@’localhost’ 应该视为一个整体,应该写成

‘developer@localhost’ 。

语句:create user ‘developer@localhost’ identified by ‘123456’;

2.建用户的时候报告这个错误,原因是mysql中已经有了这个用户,可以从mysql.user中直接删除,然后刷新权限,再建用户就不会有这个问题了。如果是drop

user先,那么mysql内部应该会自动刷新一下,那么再建也不会有这问题了。

一个老外遇到了这个问题,给了个例子。他就是没有刷新权限,才导致了这问题。

http://stackoverflow.com/questions/5555328/error-1396-hy000-operation-create-user-failed-for-jacklocalhost

mysql> CREATE USER ‘jack’@’localhost’ IDENTIFIED

BY ‘test123’;

Query OK, 0 rows affected (0.00 sec)

mysql> select user,host from

user;

—————— —————–

| user

| host

|

—————— —————–

| root

|

127.0.0.1

|

| debian-sys-maint | localhost

|

| jack

|

localhost

|

| root

|

localhost

|

| root

|

russ-elite-book |

—————— —————–

5 rows in set (0.00 sec)

mysql> delete from user where user =

‘jack’;

Query OK, 1 row affected (0.00 sec)

mysql> select user,host from

user;

—————— —————–

| user

| host

|

—————— —————–

| root

|

127.0.0.1

|

| debian-sys-maint | localhost

|

| root

|

localhost

|

| root

|

russ-elite-book |

—————— —————–

4 rows in set (0.00 sec)

mysql> CREATE USER ‘jack’@’localhost’ IDENTIFIED

BY ‘test123’;

ERROR 1396 (HY000): Operation CREATE USER failed for

‘jack’@’localhost’

这里应该:FLUSH PRIVILEGES

mysql> CREATE USER ‘jimmy’@’localhost’ IDENTIFIED

BY ‘test123’;

Query OK, 0 rows affected (0.00 sec)

mysql> select user,host from

user;

—————— —————–

| user

| host

|

—————— —————–

| root

|

127.0.0.1

|

| debian-sys-maint | localhost

|

| jimmy

| localhost

|

| root

|

localhost

|

| root

|

russ-elite-book |

—————— —————–

5 rows in set (0.00 sec)

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/169955.html原文链接:https://javaforall.cn

0 人点赞