Many times we faced below issue when try to connect a remote MySQL server from client system and remote client is not allowed to access this MySQL server we faced issue like below.
# mysql -h 192.168.1.10 -u root -p Enter password:
[Output]ERROR 1130 (HY000): Host '192.168.1.12' is not allowed to connect to this MySQL server
This issue is because that, If client system does not have permission to connect MySQL server. By default MySQL server doesn’t allow any remote clients to connect.
Allow MySQL Client Connection:
To allow a client system to connect mysql server. Login to remote mysql server using ssh and then login to MySQL server locally. Now use following commands to allow remote client. For example if remote client’s ip is
[ Below commands need to run on MySQL Server ]
# mysql -u root -p Enter password: mysql> GRANT ALL ON *.* to root@'192.168.1.12' IDENTIFIED BY 'new-password'; mysql> FLUSH PRIVILEGES; mysql> quit
You have successfully created a new account in MySQL server to connect from specified client system.
Let’s try to connect from clients system.
# mysql -h 192.168.1.10 -u root -p
[Sample Output]Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 27 Server version: 5.1.69 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql>