By default, MySQL can be connected in your mysql-server locally. You may determine to access your MySQL database to local machine remotely , should give remote permission in mysql server.
Find out your user permission status :
mysql> SELECT * from information_schema.user_privileges where grantee like "'linux_user'%";
+-------------------------------+------------------------+-----------------------------+---------------+
| GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |
+-------------------------------+-----------------------+------------------------------+----------------+
| 'linux_user'@'localhost'| def | USAGE | NO
+-------------------------------+------------------------+-----------------------------+----------------+
+-------------------------------+------------------------+-----------------------------+---------------+
| GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |
+-------------------------------+-----------------------+------------------------------+----------------+
| 'linux_user'@'localhost'| def | USAGE | NO
+-------------------------------+------------------------+-----------------------------+----------------+
Before giving permission to check your configuration my.cnf file,
vim /etc/mysql/my.cnf
Command the two lines may available in my.cnf file:
#bind-address = 127.0.0.1
#skip-networking
#skip-networking
Can be set different type of remote permission for usage,
Remote permission to all machines:
GRANT ALL PRIVILEGES ON *.* TO 'linux_user'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Remote permission specific database:
GRANT ALL PRIVILEGES ON your_database.* TO ' linux_user '@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Remote permission from specific IP Address.
GRANT ALL PRIVILEGES ON *.* TO ' linux_user '@'192.168.0.30' IDENTIFIED BY 'password' WITH GRANT OPTION;
Remote permission specific database and IP Address:
GRANT ALL PRIVILEGES ON your_database.* TO ' linux_user '@'192.168.0.30' IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> quit
mysql> FLUSH PRIVILEGES;
mysql> quit
Check whether mysql is listening properly,
SELECT * from information_schema.user_privileges where grantee like "'linux_user'%";
Test your remote database connection from terminal/command-line:
# mysql -h 192.168.0.30 -u linux_user –p
Enter Password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9131
Server version: 5.1.73-cll MySQL Community Server (GPLv2)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+-------------------------+
| Database |
+-------------------------+
| information_schema |
| your_database |
+--------------------------+
2 rows in set (0.00 sec)
Enter Password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9131
Server version: 5.1.73-cll MySQL Community Server (GPLv2)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+-------------------------+
| Database |
+-------------------------+
| information_schema |
| your_database |
+--------------------------+
2 rows in set (0.00 sec)
Comments (0)