- MySQL 8.0
- CentOS 7
- Virtual Machine or Physical Server/Desktop
- Internet on the CentOS Server
Create an operating system user named as “mysql” by logging in to the operating system root user and add the user to the “sudo” list.
# useradd mysql # passwd mysql # usermod -aG wheel mysql
Install the wget package to download the mysql yum repository.
# yum install wget
Connect to the mysql user by switch user “su” command or connecting from a new SSH session.
# su - mysql
Add the MySQL Yum repository to your system’s repository list. Got to the Download MySQL Yum Repository page (https://dev.mysql.com/downloads/repo/yum/) in the MySQL Developer Zone. Select and download the release package for your platform by the following command. In this case it will be “mysql80-community-release-el7-3.noarch.rpm”.
$ sudo wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
Install the downloaded release package with the following command.
$ sudo yum localinstall mysql80-community-release-el7-3.noarch.rpm
Check that the MySQL Yum Repository has been successfully added by the following command.
$ yum repolist enabled | grep "mysql.*-community.*"
Install MySQL by the following command.
$ sudo yum install mysql-community-server
When successfully done start the mysql server with the following command.
$ sudo service mysqld start
You can check the status of the mysql server with the following command.
$ sudo service mysqld status
A superuser account ‘root’@’localhost is created. A password for the superuser is set and stored in the error log file. Show the password by the following command:
$ sudo grep 'temporary password' /var/log/mysqld.log
Connect to the mysql server with root user created with the temporary password above and change the root password immediately as a best practice.
$ mysql -u root -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MySQL@!098';
Note: You can install the mysql database server by using operating system root user but for security concern it is not recommended.