Update Mysql Config
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Change from 127.0.0.1 to 0.0.0.0
. . .
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
. . .
Restart Mysql
sudo systemctl restart mysql
Login into Mysql
sudo mysql
mysql -u root -p
You might rename, create or alter users
** use % instead of IP to open to all IPs
RENAME USER 'user'@'localhost' TO 'user'@'remote_server_ip';
CREATE USER 'user'@'remote_server_ip' IDENTIFIED BY 'password';
ALTER USER 'user'@'remote_server_ip' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'user'@'remote_server_ip' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Open port 3306
Whitelist ip
sudo ufw allow from remote_IP_address to any port 3306
or all ip
sudo ufw allow 3306