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

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?

 Print this Article

Also Read

how do I delete a mysql database?

Login to cPanel. Locate and click on the "MySQL Databases" icon under the "Databases"...

how can I backup a mysql database?

Run one of the following commands:   /path/to/bin/mysqldump -u $mysqlusername...

how do I create a mysql database?

Login to cPanel. Locate and click on the "MySQL Databases" icon in the "Databases" category....

why do I see: error at line 2: unknown command '\_'. when I list mysql databases?

You have MySQL version 4.0.12 which has a bug that causes this error. Upgrade to a later version...

how do I remove a mysql user from a database?

Login to cPanel. Locate and click on the "MySQL Databases" icon within the "Databases"...