![]() |
How to Reset the Root Password of MySQL
I followed the steps described on this web page
http://dev.mysql.com/doc/refman/5.0/...rmissions.html for resetting the root user's password. Actually, I am using www.linuxzoo.net for online practice of Linux and have MySQL installed on it. But I forgot the password I set. There was no password by default set for the root user. So, I just trying setting a password last week. Now I am not getting what I did. Anyways, I did these things: Code:
-bash-2.05b# cat /root/mysql-initCode:
mysqld (pid 3119 3118 3117 3116) is running...Code:
-bash-2.05b# mysqld_safe --init-file=/root/mysql-initCode:
-bash-2.05b#Any help guys? :newbie: |
You can do the following to start the service with the --skip-grant-tables option:
Code:
service mysqld stopQuote:
|
Quote:
Code:
mysqld (pid 1359 1358 1357 1356) is running...Code:
-bash-2.05b# which mysqldSo I looked for mysqld... Code:
-bash-2.05b# find / -name mysqldOkay, I tried these mysqld executables... Code:
-bash-2.05b# /etc/rc.d/init.d/mysqld --skip-grant-tablesCode:
-bash-2.05b# /usr/libexec/mysqld --skip-grant-tablesSo, still no result.:doh: |
What distro and mysql version are you running and how did you install myslq?
|
Linux and MySQL Versions
Quote:
Code:
-bash-2.05b# uname -aCode:
-bash-2.05b# cat /etc/issueI didn't install it manually. There is a UML (User Mode Linux) available on www.linuxzoo.net which we can use for our practice purpose. MySQL is installed on it by default. I think I had mistyped the password otherwise I generally remember my passwords and I use which I can remember when doing some testing. But I am curious to troubleshoot it. Code:
-bash-2.05b# mysql -u root -p |
Quite old mysql version 3.23.58!!!
Quote:
Anyway to reset the password, you can try: Code:
/usr/libexec/mysqld --skip-grant-tables -u mysql & |
Code:
-bash-2.05b# service mysqld stopThanks a lot! :) |
How can we view all the user names?
I tried this... Code:
-bash-2.05b# mysql -u root -pApparently there is only root user appearing twice but the above output reports "4 rows". Why? I am also able to log in using the user name: mysql.... Code:
-bash-2.05b# mysql -u mysqlmysql> update mysql.user set password=PASSWORD('test') where user='mysql'; Query OK, 0 rows affected (0.00 sec) Rows matched: 0 Changed: 0 Warnings: 0 mysql> |
Quote:
The fact that you can connect using mysql (it's an anonymous account) is because you're running the server with "--skip-grant-tables". You can connect to the database using whatever name you want in this situation. Regards |
Quote:
Thanks for the explanation! Here is my experiment: Code:
mysql> select user from mysql.user;Code:
-bash-2.05b# mysql -u mysqlCode:
-bash-2.05b# mysql -u root -pCode:
-bash-2.05b# mysql -u mysqlCode:
-bash-2.05b# mysql -u root -pCode:
-bash-2.05b# mysql -u mysql |
| All times are GMT -5. The time now is 09:28 PM. |