How to connect mysql server remotely?

How to connect mysql server remotely?

1)Connect to database

root@MySql:/# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 29
Server version: 10.3.22-MariaDB-0ubuntu0.19.10.1 Ubuntu 19.10

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

2)Create new user and grant privileges

You have to select the ipaddress of host

Check host ip

root@MySql:/# ifconfig

Flush the privileges to make the changes permanent on disk

MariaDB [(none)]> create user 'test'@'10.0.0.5' identified by 'password';
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> grant all on *.* to 'test'@'10.0.0.5';
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)

Check the user status

MariaDB [(none)]> select user,host from mysql.user;
+--------+----------------+
| user   | host           |
+--------+----------------+
| test   | 10.0.0.5       |
+--------+----------------+

Connect remotely by mysql workbench

Database –> Connect to database

Click on the plus symbol to connect to database

Fill the connection details and give the password to connect

You are successfully connected from remote client!!!

Leave a Reply

%d bloggers like this: