Sunday, January 5, 2020

How to connect mysql remotely in linux

In this post I will show you, How to create a new user and grant permissions in MySQL

Previously I had shown..
Config file Paths in different operating systems. Lets check the paths as shown and open in nano using below command

MySQL in Ubuntu 16:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
MariaDB in Raspberry Pi:

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Locate bind-address and change as shown. This will allow to connect with any IP address

bind-address = 0.0.0.0
Now restart mysql.

sudo systemctl restart mysql.service
sudo systemctl restart mariadb.service
Now login to MySQL with root

mysql -u root -p
Now grant permission as shown

GRANT ALL privileges ON *.* TO username@'%' IDENTIFIED BY 'user_password';
FLUSH PRIVILEGES;
quit;
Ones again restart MySQL

sudo systemctl restart mariadb.service
Now connect with Mysql GUI tools from other computers. Here I'm using HeidiSQL.
[Note:] Hostname/IP = MySQL Installed OS IP Address.


















Command to connect

mysql -h mysql server ip -u root -p
Ex: mysql -h 192.168.1.20 -u root -p

No comments:

Post a Comment