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'@'' identified by 'password';
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> grant all on *.* to 'test'@'';
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   |       |

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

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s