Remote MySQL Connections

You may need to enable non-localhost connections to a MySQL database as a part if website development and its structure. It’s easy to do it on any Linux-based servers.

 

1). Connect to your server via SSH as root.

 

2). Log into MySQL as root and enter the following command:

 

GRANT ALL PRIVILEGES ON database.* TO user@'IP' IDENTIFIED BY 'password';

 

where, 

* database is replaced by the name of the database you’d like to allow access to. Using * will allow access to all databases.

* user is replaced by the username you want to allow.

* IP is replaced by the actual IP to connect from. Using % will allow access from all IPs.

* password is replaced by the desired password.

 

3). Apply changes you’ve made with the following command:

 

FLUSH PRIVILEGES;

 

4). You might also need to allow connections to port 3306 (standard MySQL port) from a remote IP. Run the following command in shell:

 

iptables -I INPUT -s IP -p tcp --dport 3306 -j ACCEPT

 

Don’t forget to replace IP with the actual IP you want to allow MySQL connections from.

  •  
  • 150 Users Found This Useful
Was this answer helpful?

Related Articles

How To Install and Use Docker on Ubuntu 16.04

Introduction Docker is an application that makes it simple and easy to run application processes...

Backup and Restore cPanel Accounts via SSH

a. How to create a backup of a cPanel Account via SSH?   1. Log-in to the SSH as the Root...

Change Main IP of the server :: Vesta Panel

If we are changing the main IP of a server installed with Vesta panel, we can use the following...

Change permissions using find command

On a Linux server, if you are in need of changing the permissions of a bulk amount of files or...

Change the time of your vps/dedi

It's very easy, you first need to remove the current time file rm /etc/localtime and replace it...