Thursday, February 17, 2022

Setting up a Remote MySQL 8 Database Connection

 in This Tutorial you will Learn " How To Allow Remote Connection to MySQL 8 Database Server On Rocky Linux 8"
By default, MySQL is configured to allow connections only from the localhost. You will need to allow remote access to the MySQL database server if your application and database are hosted on different servers.

MySQL is an open source SQL database management system developed by Oracle Corporation.
________________________________________________________________________________________
Server - Os:  Rocky Linux 8.5  64Bit      | IP -192.168.1.60        |Hostname - server.yourdomain.com
_________________________________________________________________________________________
dnf groupinstall "Development Tools" -y ; dnf module -y install mysql:8.0
nano /etc/my.cnf.d/mysql-server.cnf
character-set-server=utf8mb4
firewall-cmd --add-service=mysql --permanent ; firewall-cmd --reload
systemctl enable --now mysqld ; systemctl start mysqld ; mysql_secure_installation

[ remote-server-ip- 192.168.1.80 ]
mysql -u root -p
CREATE DATABASE testdb;
CREATE USER 'testuser'@'192.168.1.80' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'192.168.1.80';         
FLUSH PRIVILEGES ;
SHOW GRANTS FOR 'testuser'@'192.168.1.80';
EXIT;
_________________________________________________________________________________________
sestatus ; hostname -I
Verify Database Connection -  mysql -u testuser -h 192.168.1.60 -p
show databases;
status;
show processlist;
_________________________________________________________________________________________



No comments:

Post a Comment