mysql 创建用户
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1667574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql CREATE USER
提问by Lizard
I am logged into mysql...
我登录了mysql...
mysql -u root -pmypass
And I have run the following command to remove the database user which worked succesfully
我已经运行以下命令来删除成功运行的数据库用户
mysql> FLUSH PRIVILEGES; DROP USER 'myuser_shop';
I can then add user successfully using the following command, again this works successfully
然后我可以使用以下命令成功添加用户,这再次成功
mysql> FLUSH PRIVILEGES; CREATE USER 'myuser_shop' IDENTIFIED BY 'mypass';
The above command create a user with the host as a wildcard (%) The issue I am having is if I was to create a user with the host being say localhost or an external IP i get the following error:
上面的命令创建一个用户,主机作为通配符 (%) 我遇到的问题是,如果我要创建一个主机为 localhost 或外部 IP 的用户,我会收到以下错误:
mysql> FLUSH PRIVILEGES; DROP USER 'myuser_shop';
mysql> FLUSH PRIVILEGES; CREATE USER 'myuser_shop'@'localhost' IDENTIFIED BY 'mypass';
Query OK, 0 rows affected (0.00 sec)
ERROR 1396 (HY000): Operation CREATE USER failed for 'myuser_shop'@'localhost'
Any suggestions?
有什么建议?
Thanks in advance
提前致谢
采纳答案by Svetlozar Angelov
This is a bug reported here - http://bugs.mysql.com/bug.php?id=28331
这是这里报告的错误 - http://bugs.mysql.com/bug.php?id=28331
See if your user exists after you drop it.
删除后查看您的用户是否存在。
回答by Alexei Tenitski
Check following 2 tables if user is still there after DROP USER command: mysql.user and mysql.db.
如果用户在 DROP USER 命令后仍然存在,请检查以下 2 个表:mysql.user 和 mysql.db。
Delete user from both, then run FLUSH PRIVILEGES and then you can recreate the user.
从两者中删除用户,然后运行 FLUSH PRIVILEGES,然后您可以重新创建用户。
回答by Humberto
drop user 'username@localhost '
删除用户 'username@localhost'
回答by insCode
i will suggest you to use phpmyadmin its very esey do do with that.
我会建议你使用 phpmyadmin,它很容易做到这一点。
steps:
脚步:
- open phpmyadmin
- go to admin section
- hit on add user account
- put user name and password
- set privileges
- 打开 phpmyadmin
- 转到管理部分
- 点击添加用户帐户
- 输入用户名和密码
- 设置权限
that's all see in action on youtube [ click here ]
这都是在 youtube 上看到的 [点击这里]
回答by marek rodkiewicz
You have to manualy remove records with from mysql.tables_priv also.
您还必须手动从 mysql.tables_priv 中删除记录。