How To Configure Remote And Secure Connections for MySQL on CentOS 7
MySQL is an open source SQL database management system developed by Oracle Corporation.SQL stands for Structured Query Language, which is a standardized language used to access databases.
MySQL is a relational database management system (RDBMS). This means that the database stores data in separate tables, with structures organized into physical files optimized for speed. Users set up rules governing the relationships between different data fields, using SQL.yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
yum install -y mysql-community-server
systemctl start mysqld && systemctl enable mysqld
netstat -plntu | grep mysql
grep ‘temporary password’ /var/log/mysqld.log
Default MySQL Root Password:- YbKZd3++-dmr
New Password :- Tk@VDam2u4CtW+bV
mysql -u root -p
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘Tk@VDam2u4CtW+bV’;
FLUSH PRIVILEGES;
EXIT;
Enable SSL for MySQL:- By default, MySQL Has its Own SSL Certificates, Stored in /var/lib/mysql. For The purpose of this Tutorial, These Certificates r good enough.
Note: in production, always use more secure and “personal” certificates.
mysql -u root -p
SHOW GLOBAL VARIABLES LIKE ‘%ssl%’;
STATUS;
nano /etc/my.cnf
ssl-ca=/var/lib/mysql/ca.pem
ssl-cert=/var/lib/mysql/server-cert.pem
ssl-key=/var/lib/mysql/server-key.pem
bind-address = *
require_secure_transport = ON
[client]
ssl-ca=/var/lib/mysql/ca.pem
ssl-cert=/var/lib/mysql/client-cert.pem
ssl-key=/var/lib/mysql/client-key.pem
systemctl restart mysqld
mysql -u root -p
STATUS;
Creating New User for Remote Connections:-
mysql -u root -p
create user ‘example’@’%’ identified by ‘exampleS123@’ REQUIRE X509;
grant all privileges on *.* to ‘example’@’%’ identified by ‘exampleS123@’ REQUIRE X509;
flush privileges;
exit
======================================================
centos 7