在 ubuntu 上忘记 MySQL 用户名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18719765/
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
Forgotten MySQL username on ubuntu
提问by Ema4rl
I've forgotten my MySQL owner details. I need a way to find my username. My password will not be a problem. I use Ubuntu 12.04 Linux, and would prefer a command line solution.
我忘记了我的 MySQL 所有者详细信息。我需要一种方法来找到我的用户名。我的密码不会有问题。我使用 Ubuntu 12.04 Linux,并且更喜欢命令行解决方案。
Thank you in advance.
先感谢您。
回答by Alma Do
Well, then you have a clear way to restore it:
那么,你有一个明确的方法来恢复它:
- Run your MySQL server with skipping grant tablesoption.
- Log in as root
Run query
SELECT DISTINCT user FROM mysql.user
That's it - you have a list of users. Save it somewhere, then run server normally and try your user names one by one.
- 使用跳过授权表选项运行您的 MySQL 服务器。
- 以 root 身份登录
运行查询
SELECT DISTINCT user FROM mysql.user
就是这样 - 您有一个用户列表。保存在某处,然后正常运行服务器并一一尝试您的用户名。
Tip: if you want to reset root password, there's a corresponding manual page.
提示:如果你想重置root密码,有相应的手册页。
回答by Kārlis Millers
Well there is simple way how to change mysql user password as root
那么有一个简单的方法如何以 root 身份更改 mysql 用户密码
mysql -u root -p password
mysql> SET PASSWORD FOR username = PASSWORD('new_password_here');