To install MySQL, in the terminal window, type the following command:
#sudo yum -y install @mysql
Once the install completes, start the MySQL Service:
#systemctl start mysqld
Enable it to automatically start at system boot
systemctl enable --now mysqld
Next, verify the status
#systemctl status mysqld
Thereafter, secure the MySQL installation by running the security script:
#mysql_secure_installation
This script sets the MySQL root password, allows one to remove anonymous users, and allows one to allow or disable “root” from logging in remotely.
Once MySQL is secure, you can log in to the MySQL shell:
#mysql -u root -p
You can create a new database
#create database newDB;
You can also create a new user
#GRANT ALL ON newDB.* TO 'newuser'@'localhost' IDENTIFIED BY 'password';
If trying to access the database from a remote computer and one receives the following error: “xxx.xxx.xxx.xxx is not allowed to connect to this MySQL Server”, simply create a user account and grant privileges to that remote user.
#CREATE USER 'newuser'@'remote_ip' IDENTIFIED BY 'password';
#GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'remote_ip' WITH GRANT OPTION;
OR
#CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
#GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'%' WITH GRANT OPTION;
#FLUSH PRIVILEGES;