Installation Process and Initial Setup
First, remove any existing MariaDB installations that might conflict:
yum remove mariadb-libs.x86_64
Download the MySQL repository configuration package:
cd /tmp
wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
Install the downloaded repository:
yum localinstall mysql80-community-release-el7-2.noarch.rpm
Proceed with MySQL server installatoin:
yum install mysql-community-server
Verify MySQL service status:
ps -ef | grep mysql
Service control commands:
service mysqld start # Start MySQL
service mysqld restart # Restart MySQL
service mysqld stop # Stop MySQL
Retrieve the temporary root password generated during installation:
grep 'temporary password' /var/log/mysqld.log
Connect to MySQL using the root user:
mysql -u root -p
Password Policy Configuration
When attempting to view databases immediately after login, you may encounter a password reset requirement:
SHOW DATABASES;
-- Error: You must reset your password using ALTER USER statement
To simplify the password policy for development environments:
-- Set temporary simple password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'simplepass';
-- Disable password complexity requirements
SET GLOBAL validate_password.policy = LOW;
SET GLOBAL validate_password.length = 4;
-- Set final password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysql';
Enabling Remote Access
To allow remote connnections to the MySQL server, modify the user permissions:
mysql -u root -p
USE mysql;
-- Allow root access from any host
UPDATE user SET host = '%' WHERE user = 'root' AND host = 'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
-- Apply changes
FLUSH PRIVILEGES;
EXIT;
Restart the MySQL service for changes to take effect:
service mysqld restart
Note: If encountering authentication protocol errors with older clients like Navicat 11.1.13, upgrade to a newer client version that supporst MySQL 8.0's authentication mechanism.
General Query Log Configuration
Enable MySQL's general query log to monitor all SQL statements:
-- Connect to MySQL and execute:
SET GLOBAL general_log_file = '/tmp/mysql_general.log';
SET GLOBAL general_log = 'ON';
To disable logging:
SET GLOBAL general_log = 'OFF';
Monitor the log in real-time from another terminal:
tail -f /tmp/mysql_general.log