Remote Access To MySQL Database Server on ubuntu from Any Computer


Login MYSQL Server computer by 'SSH Secure Shell Client'
ssh username@ip
   Example: ssh a@192.168.1.96
Enter pc password

Login MYSQL Server  mysql -u[username] -p[password]
   Example: mysql -uroot -pabcd ;



Set bind-address   = 0.0.0.0 on my.cnf for access any computerEdit mysql my.cnf
   $ nano /etc/mysql/my.cnf
   Set bind-address   = 0.0.0.0

Save my.cnf file and exit.  

Check '%' Host and 'root' User on user table
    mysql>  SELECT * FROM mysql.user WHERE HOST='%' AND User='root';


If '%' Host and 'root' User do not exist on user table. Execute below sql query    Mysql> GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'mysql_password'  WITH GRANT OPTION
     Example: GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY ‘abcd’ WITH GRANT OPTION
Logout from mysql server
    mysql> exit;

Restart MySql server:
   $ sudo/etc/init.d/mysql restart
To Check remote to remote enable
   mysql -u[root] -p[password] -h[mysql_serverip]
   Example; mysql -uroot -pabcd -h192.168.1.96

No comments:

Post a Comment