Details


Symptoms

You are getting the following error message when connecting to a MySQL database.

Access denied for user 'root'@"hostname" (using password: YES)

OR

Access denied for user 'userName'@"hostname" (using password: YES)

By default, MySQL database only allows access from the local machine and using the 'root' account. If you need clients to connect from other machine using accounts other than 'root', you need to run the following script to create additional accounts.

GRANT ALL PRIVILEGES ON *.* TO 'userName'@'localhost'
    IDENTIFIED BY 'password' WITH GRANT OPTION

go
GRANT ALL PRIVILEGES ON *.* TO 'userName'@'%'
    IDENTIFIED BY 'password' WITH GRANT OPTION

IMPORTANT: Replace 'userName' and 'password' with appropriate values in the script. For more information about security in MySQL refer to this link on MySQL's website.

In order to run the above query, you must be on the same machine where MySQL is installed. If you have installed MySQL database on Linux/UNIX machine where you cannot run WinSQL, try using the mysql command line utility that comes with MySQL database.

From the local machine, you should be able to connect using root as the user id and a blank password. If you are not able to connect using a blank string for password, it is likely that you changed the value of the root password during installation. Therefore, use that value instead for password.

For more information about security in MySQL, refer to this link.

Navigation

Social Media

Powered by 10MinutesWeb.com