- edit file: /etc/my.cnf.d/server.cnf
- Mã: Chọn tất cả
[mysqld]
...
skip-networking
...
bind-address = <some ip-address>
...
to
- Mã: Chọn tất cả
[mysqld]
...
#skip-networking
skip-networking=0
...
#bind-address = <some ip-address>
skip-bind-address
...
- Restart MySQL:
systemctl restart mariadb
- You can now verify the MariaDB listening status with the following command:
netstat -ant | grep 3306
- If everything is fine, you should get the following output:
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
- Now, the MariaDB server is setup to listen to all IP addresses.
II - Grant Access to a User from a Remote System:
- First, login to the MariaDB shell with the following command:
mysql -u root -p
CREATE USER 'root'@'12.34.56.78' IDENTIFIED BY 'password123456';
GRANT ALL ON *.* TO 'root'@'12.34.56.78';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'12.34.56.78' IDENTIFIED BY 'password123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
SELECT User,Host FROM mysql.user;
III - Port 3306 is Configured in Firewall
- One more point to consider whether the firwall is configured to allow incoming request from remote clients:
- On RHEL and CentOS 7, it may be necessary to configure the firewall to allow TCP access to MySQL from remote hosts. To do so, execute both of these commands:
firewall-cmd --add-port=3306/tcp
firewall-cmd --permanent --add-port=3306/tcp
- Test remote MYSQL on VPS 12.34.56.78:
mysql -u root -h 111.222.333.444 -p
Explore more: https://mariadb.com/kb/en/configuring-mariadb-for-remote-client-access/