Knowledgebase

why does mysql give an access denied error for root@localhost?  Print this Article

To avoid this issue, ensure that the MySQL root password is in the /root/.my.cnf file on the password line.

  • This is usually the first root password given when cPanel was installed.

If the MySQL root password is not in the /root/.my.cnf file, reset the mysqld root password with the following steps:

1. Run the /etc/rc.d/init.d/mysql stop command to stop mysqld.
2. Stop tailwatchd and temporarily disable it:

# touch /etc/tailwatchddisable
# killall tailwatchd

3. Run the mysqld --skip-grant-tables -u mysql command to start mysqld.
4. Run the # mysql -u root mysql -e "UPDATE user SET Password=PASSWORD('new_password') WHERE user='root'; FLUSH PRIVILEGES;" command to change the password.
5. Run the killall mysqld command to start the MySQL normally with the safe_mysqld script.
6. Run the /scripts/restartsrv_mysql command.
7. Delete the tailwatchddisable file you created with the rm /etc/tailwatchddisable command.
8. Run the /scripts/restartsrv_tailwatchd command.

Was this answer helpful?

Also Read

how do I export a mysql database?
Login to cPanel. Locate and click on the "phpMyAdmin" icon under the "Databases" category....
how do I import a mysql database?
Login to cPanel. Locate and click on the "phpMyAdmin" icon under the "Databases" category....
how do I delete a mysql user?
Login to cPanel. Locate and click on the "MySQL Databases" icon under the "Databases"...
how do I delete a mysql database?
Login to cPanel. Locate and click on the "MySQL Databases" icon under the "Databases"...