Thursday, November 5, 2020

Connect mysql by remote server in ubuntu linux

In this tutorial we are configuring remote connection for mysql 8 Version


Step 1)
Allow 3306 port in firewall

Step 2) allow user and his system ip in mysql

mysql -u root -p


  •  If user not created then create user and passwd

mysql > CREATE USER 'demouser'@'10.10.10.20' IDENTIFIED WITH mysql_native_password BY '123456';

or give Access to EveryOne

mysql > CREATE USER 'demouser'@'%' IDENTIFIED WITH mysql_native_password BY '123456';


  •  Create database & grant all privileges

mysql> CREATE DATABASE demo_db;

mysql > GRANT ALL on demo_db.* TO 'demouser'@'10.10.10.20' WITH GRANT OPTION;  

Or

mysql > GRANT ALL on demo_db.* TO 'demouser'@'%' WITH GRANT OPTION;


mysql > FLUSH PRIVILEGES;

mysql > EXIT;

 

Step 3) Change bind ip in /etc/mysql/mysql.conf.d/mysqld.cnf


   bind ip : 127.0.0.1
                to
             0.0.0.0          (allow all ip or give specific)


Step 4) sudo service mysql restart


Step 5) mysql -u flex -h mysql_server_ip -p database_name

                                OR

 mysql -u flex -h mysql_server_ip -p

 

Step 6)  If still not connected, so please check firewall rules.

sudo service ufw status
sudo service firewalld status

 

No comments:

Post a Comment

testing