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 add a user to a mysql database?
Login to cPanel. Locate and click on the "MySQL Databases" icon under the "Databases"...
when I try to load sql dump, I receive the following: error 2006: mysql server has gone away?
To address this issue, perform the following:   Open the /etc/my.cnf file with your preferred...
how do I remove a mysql user from a database?
Login to cPanel. Locate and click on the "MySQL Databases" icon within the "Databases"...
how can I search the databases?
Write what are you looking for in the Search field. Click Go.
how do I create a mysql database?
Login to cPanel. Locate and click on the "MySQL Databases" icon in the "Databases" category....