If you are trying to access your database server remotely and getting below error during MySQL login:
Then this article will help you to resolve this issue. In this article I will show you how to fix this error.
Mostly this error comes when your root user only have been added with localhost access. You can check using below command, first of all go to your mysql database server and type the below command to check:
mysql> SELECT host FROM mysql.user WHERE User = 'root'; +-----------+ | host | +-----------+ | 127.0.0.1 | | ::1 | | localhost | +-----------+ 3 rows in set (0.00 sec)
As you can see that root is only allowed from localhost 127.0.0.1. you cannot connect from an external source. If you see other IP addresses.
Next You will need to add the IP address of each system that you want to grant access to, and then grant privileges like below:
CREATE USER 'root'@'ip_address' IDENTIFIED BY 'some_pass'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip_address';
You can also allow your root to connect from any remote source use the below command:
CREATE USER 'root'@'%' IDENTIFIED BY 'some_pass'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
Finally, reload the permissions, and you should be able to have remote access:
If still you are getting same error check open your my.cnf file and check for below line:
bind-address = 127.0.0.1
Now Comment out the bind address from the file /etc/mysql/my.cnf.
#bind-address = 127.0.0.1
Next restart mysqld service to apply above changes.
# /etc/init.d/mysqld restart