MySQL was originally developed by MYSQL AB and is now owned by Oracle Corporation. It was the primary database application for the Linux operating system until the release of MariaDB, a fork of MySQL.
Add MySQL Repository
MySQL is neither distributed through the base operating system image nor available in OS repositories. So, you would need to its official repository to install the MySQL community server.
yum install https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
Run the below command to ensure sure the MySQL repository has been added and enabled.
yum repolist all | grep mysql | grep enabled
mysql-connectors-community/x86_64 MySQL Connectors Communit enabled: 95 mysql-tools-community/x86_64 MySQL Tools Community enabled: 84 mysql80-community/x86_64 MySQL 8.0 Community Serve enabled: 82
Install MySQL 8.0 Community Server
yum -y install mysql-community-server
Start MySQL server
After the installation of the MySQL package, you can start MySQL server using the following command.
systemctl start mysqld
Enable MySQL server at system startup.
systemctl enable mysqld
Verify that the MySQL server is running using the following command.
systemctl status mysqld
Secure MySQL server
In CentOS, initial MySQL root password can be found in
/var/log/mysqld.log. You can use the below command to take the password from the log file. This password is required for making the MySQL server secure.
cat /var/log/mysqld.log | grep -i 'temporary password'
2019-03-19T04:19:04.444173Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: X.khdzie1q95
mysql_secure_installation to secure your MySQL installation.
This command performs initial tasks such as setting the root password, removing anonymous users, disallow root login remotely, etc.
Work with MySQL Server
Login to MySQL server with the root and the password you set while securing the MySQL.
mysql -u root -p
Enter password: <== Enter MySQL root Password Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 Server version: 8.0.15 MySQL Community Server - GPL Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
You have successfully installed MySQL 8.0 on CentOS 7. If you are a newbie and not comfortable in MySQL command line mode, you can use phpMyAdmin, an open source web-based management tool to manage MySQL and MariaDB databases.