Configure the MySQL source and install MySQL using yum under CentOS 7

  • 2020-05-12 06:43:45
  • OfStack

The default database of CentOS7 is mariadb, so I decided to change it to mysql because I was not used to the configuration, but the default of yum source of CentOS7 does not seem to have mysql. To solve this problem, we will download the repo source for mysql.

1. Since mysql is not available in CentOS's yum source, you need to download the yum repo configuration file from mysql's official website.


wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2. Install the yum repo file


rpm -ivh mysql57-community-release-el7-9.noarch.rpm

In/after completes etc/yum repos. d/directory generates two repo files mysql - community. repo mysql - community - source. repo

3. Then update the yum cache


yum clean all
yum makecache

4. Install mysql


yum install mysql-community-client.x86_64 mysql-community-common.x86_64 mysql-community-devel.x86_64 mysql-community-libs.x86_64 mysql-community-server.x86_64

or


rpm install mysql-server

5. Start mysql


service mysqld start

6. View the initial password


grep 'temporary password' /var/log/mysqld.log

Get the following:

2016-10-28T10:36:32.369073Z 1 [Note] A temporary password is generated for root@localhost: 5Oazqgpiat!p

Log in with your initial password


mysql -u root -p // Enter and type in 1 Initial password found by step 

8. Change the initial password


ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
// Now, mysql High password strength requirements, need to include upper and lower case letters, Numbers and special characters 

At this point, the installation of mysql-server is complete


Related articles: