VDS Sphera Knowledge Base

Main / Browse Categories / MySQL / How can I reset my main MySQL root password?

Print article Print Article    Email article Email Article

How can I reset my main MySQL root password?
Note: The PhpMyAdmin ValueApp uses the password that is specified in the /etc/my.cnf file. If you have recently modified your MySQL password make sure that you update the /etc/my.cnf file to reflect the change.

If you have misplaced your MySQL password and can no longer connect to the MySQL server, this article explains how you can either find the original MySQL password or reset it.

Finding the Original MySQL Password

Login to your VDS via SSH and view your /etc/my.cnf file.

You should see something similar to this:

[client]
password        = YOUR_PASSWORD
port            = 3306
user            = root
socket          = /var/lib/mysql/mysql.sock
"YOUR_PASSWORD" should be the original password that was setup when the MySQL ValueApp was installed.

Resetting your MySQL server password

1) Login to your VDS via SSH

2) Stop your MySQL server with either of the following commands:

/etc/rc.d/init.d/mysql stop
/etc/rc.d/init.d/mysqld stop

3) Make sure that all of the MySQL processes are actually stopped or killed.

You can check for running MySQL processes with this command:

ps waux
If any MySQL processes are still running, they will look similar to the following:
2102 32523 ... /bin/sh /usr/local/mysql/bin/safe_mysqld ...
2102 32557 ... /usr/local/mysql/libexec/mysqld --basedir= ...
You can kill the processes with the kill command(Note: The second column is the Process ID or PID.):
kill -9 32523
4) Once all of the MySQL processes are killed and no longer running, you can have MySQL start without checking the permissions by executing the following command (Note: Once you execute this command you will have to open a new SSH terminal to finish resetting the password.).
/usr/local/mysql/bin/safe_mysqld --skip-grant-tables
Open a new terminal window and you should now be able to connect to MySQL via the MySQL client utility, using this command:
/usr/local/mysql/bin/mysql mysql
Then, execute the following command (Note: Replace YOUR_PASSWORD with your actual password.):
UPDATE user SET Password=PASSWORD('YOUR_PASSWORD') 
WHERE Host='localhost' AND User='root';
Then, run the command:
exit;
5) Finally, login to your VDS Control panel and restart your VDS.

User Comments
How can I reset my main MySQL root password?  
There are no user comments for this topic.
 

Attachments
No attachments.

Related Articles
 How can I connect to MySQL using SSH?
 How can I dump a MySQL database from the command line?
 My Disk Quota is unusually high. What can I do?
 Where is MySQL located?
 Where is the MySQL log file?

Why Choose Our Hosting?

Continue reading »

Featured Hosting Plan


Learn more about our VPS Extreme

What is Included?

  • PHP 5/MySQL 5
  • Plesk Control Panel
  • Unique IP Address
  • SAS Hardware Raid diskspace
  • CentOS 5 x86_64 bit
  • Multi-homed Tier 1 Bandwidth
  • Full Upgrade capabilities
Continue reading »