In this is tutorial we will see how to access MySQL 10.4 database remotely.
For this demonstration, we are using CentOS 7 and MariaDB 10.4.
1. Access the server via SSH
2. Login into MySQL
# mysql -u root -p
3. Grant user for remote access using following command:
mysql> GRANT ALL ON mydb.* TO ‘admin’@’18.104.22.168’ IDENTIFIED BY ‘Password’;
- We’re using GRANT command to enable access for remote user.
- mydb.* – replace the mydb to your actual database name that you want to access remotely.
- admin – replace it with the username you want to set for remote access.
- 22.214.171.124 – replace it with you computer’s public IP.
- Password – enter your password.
This command will grant all permission of that mentioned database to new user when user connects from the specified IP address.
4. Test the connection remotely
# mysql -u admin -p -h 126.96.36.199
188.8.131.52 – replace it with IP address of the MySQL server.
You will be asked for Enter Password: , enter the password we have set earlier in GRANT command.
After the successful login, you will see something like:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.4.13-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
That’s it. We have seen how to access MySQL 10.4 database remotely in CentOS 7.