MySQL根删除或丢失密码?

时间:2021-03-01 20:14:42

I lost my root privileges on localhost/phpmyadmin and I don't know if I accidentally deleted root or if I lost my root password... :

我在localhost / phpmyadmin上丢失了root权限,我不知道是否意外删除了root或者我丢失了root密码......:

- When I type "root" with no password on config.inc.php, I can access to localhost/phpmyadmin but I can't see my databases nor my privileges. I have nothing.

- 当我在config.inc.php上输入没有密码的“root”时,我可以访问localhost / phpmyadmin但我看不到我的数据库和我的权限。我一无所有。

- When I type "root" with some possible passwords, they all fail. I tried every logins and passwords possibilties, I always get the #1045 error (password: "YES")

- 当我用一些可能的密码键入“root”时,它们都会失败。我尝试了每个登录和密码可能,我总是得到#1045错误(密码:“是”)

- In my console server (ubuntu via PuTTY), I can type mysql -u root -p and access to MySQL with a password...

- 在我的控制台服务器(通过PuTTY的ubuntu)中,我可以输入mysql -u root -p并使用密码访问MySQL ...

Can someone please help me? Thank you!

有人可以帮帮我吗?谢谢!

2 个解决方案

#1


try using the username and password from debian.conf You can look it up using

尝试使用debian.conf中的用户名和密码。您可以使用它查找

sudo cat /etc/mysql/debian.cnf 

Log in using commandline/putty

使用命令行/ putty登录

$ mysql -u debian-sys-maint -p 

mysql> GRANT ALL ON *.* TO 'root'@'localhost';
mysql> FLUSH PRIVILEGES;

Once logged in you can restore the privileges for that user.

登录后,您可以恢复该用户的权限。

#2


I run Debian 8. I was using the Debian Wiki to install the LAMP stack, and in the process lost track of my MySQL password, which prevented my logging in to phpmyadmin toward the end, to test my access. I spent most of an entire afternoon reading the experiences of others to get to a point of having access to my MySQL account through phpmyadmin. I seemingly exhausted all efforts and then it dawned on me that I might simply be able to uninstall mysql-client and mysql-server through

我运行Debian 8.我正在使用Debian Wiki来安装LAMP堆栈,并且在此过程中丢失了我的MySQL密码,这阻止了我到目前为止登录phpmyadmin来测试我的访问权限。我花了整整一个下午的大部分时间阅读其他人的经验,以便通过phpmyadmin访问我的MySQL帐户。我似乎已经筋疲力尽了所有的努力,然后我突然意识到我可能只是能够通过以下方式卸载mysql-client和mysql-server

# aptitude remove mysql-client mysql-server

and then turning right around and reinstalling them. This worked, and by doing so I was able to reset my password, without losing track of it, and then use my new password to log in through phpmyadmin with username "root". Based on my reading, this username is applicable to all installations of mysql/phpmyadmin, so it should be the same username for anybody else using mysql/phpmyadmin. I am assuming at this point that non-root, or subordinate, users and usernames will in all probability be unique to the individual users of this software. Happy coding!

然后右转并重新安装它们。这样做了,通过这样做,我能够重置我的密码,而不会丢失它,然后使用我的新密码通过phpmyadmin用户名“root”登录。根据我的阅读,这个用户名适用于mysql / phpmyadmin的所有安装,因此对于使用mysql / phpmyadmin的任何人来说,它应该是相同的用户名。我现在假设非root用户或从属用户和用户名很可能对该软件的各个用户是唯一的。快乐的编码!

#1


try using the username and password from debian.conf You can look it up using

尝试使用debian.conf中的用户名和密码。您可以使用它查找

sudo cat /etc/mysql/debian.cnf 

Log in using commandline/putty

使用命令行/ putty登录

$ mysql -u debian-sys-maint -p 

mysql> GRANT ALL ON *.* TO 'root'@'localhost';
mysql> FLUSH PRIVILEGES;

Once logged in you can restore the privileges for that user.

登录后,您可以恢复该用户的权限。

#2


I run Debian 8. I was using the Debian Wiki to install the LAMP stack, and in the process lost track of my MySQL password, which prevented my logging in to phpmyadmin toward the end, to test my access. I spent most of an entire afternoon reading the experiences of others to get to a point of having access to my MySQL account through phpmyadmin. I seemingly exhausted all efforts and then it dawned on me that I might simply be able to uninstall mysql-client and mysql-server through

我运行Debian 8.我正在使用Debian Wiki来安装LAMP堆栈,并且在此过程中丢失了我的MySQL密码,这阻止了我到目前为止登录phpmyadmin来测试我的访问权限。我花了整整一个下午的大部分时间阅读其他人的经验,以便通过phpmyadmin访问我的MySQL帐户。我似乎已经筋疲力尽了所有的努力,然后我突然意识到我可能只是能够通过以下方式卸载mysql-client和mysql-server

# aptitude remove mysql-client mysql-server

and then turning right around and reinstalling them. This worked, and by doing so I was able to reset my password, without losing track of it, and then use my new password to log in through phpmyadmin with username "root". Based on my reading, this username is applicable to all installations of mysql/phpmyadmin, so it should be the same username for anybody else using mysql/phpmyadmin. I am assuming at this point that non-root, or subordinate, users and usernames will in all probability be unique to the individual users of this software. Happy coding!

然后右转并重新安装它们。这样做了,通过这样做,我能够重置我的密码,而不会丢失它,然后使用我的新密码通过phpmyadmin用户名“root”登录。根据我的阅读,这个用户名适用于mysql / phpmyadmin的所有安装,因此对于使用mysql / phpmyadmin的任何人来说,它应该是相同的用户名。我现在假设非root用户或从属用户和用户名很可能对该软件的各个用户是唯一的。快乐的编码!