loading...

September 16, 2022

Configure MySQL(MariaDB) for remote connections

Requirements

Summary

If you want to connect to your local/production environments MySQL server from your own network follow the tutorial carefully and you will achieve your goal.

Security note

Be careful about your production environment, its best to remove the MySQL port when you don’t need it anymore.

Create a database

Fill in your preferred settings and click on Create Database.

CyberPanel

Open PHPMyAdmin to see your database.

CyberPanel
CyberPanel

Success!

Configure Firewall for MySQL(MariaDB)

Open Firewall settings under Security in CyberPanel.

Add MySQL port 3306 to the firewall with following settings.
Click here to get your Public IPv4 Address

Name: MySQL
Protocol: tcp
IP Address: Your Public IPv4 Address
Port: 3306
CyberPanel

Add new user with all privileges

Open PuTTY and connect to your production environment.

Run the following 2 commands to add a new user with all privileges. Click here to read more about this.

mysql
GRANT ALL PRIVILEGES ON *.* to 'yourdbusernamehere'@'youripv4publicaddress' IDENTIFIED BY 'yourdbpasswordhere';
Bash Command

Success!

Manage privileges

Open PHPMyAdmin and click on User accounts.

PhpMyAdmin

Here you will see all your MySQL users present on your server & the user with ALL PRIVILEGES we just added using the commands above.

On your production environment you will see this user with Host name as your public IPv4 address.

PhpMyAdmin

We can limit the privileges by clicking on Edit privileges.

PhpMyAdmin

On this page we can manage what the user can do on our server.

PhpMyAdmin

Click here to read about available privileges.

Delete user

Select the user and click Go under Remove selected user accounts. To remove the user entirely from your MySQL server.

PhpMyAdmin
Posted in EnvironmentTaggs: