Install MySQL8 on Centos7 using rpm’s

MySQL is one of the most advanced open source database which is widely used. Below is the procedure to install MySQL8 on Centos7 using rpm packages.
- Download mysql from MySQL :: Download MySQL Community Server
- select Redhat 7 as operating system
- select “RPM Bundle” from the list.
- Copy tar file to server and open command prompt and un-tar the file.
- You can see below list of files
mysql-community-client-8.0.22-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm
mysql-community-common-8.0.22-1.el7.x86_64.rpm
mysql-community-devel-8.0.22-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.22-1.el7.x86_64.rpm
mysql-community-libs-8.0.22-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.22-1.el7.x86_64.rpm
mysql-community-server-8.0.22-1.el7.x86_64.rpm
mysql-community-test-8.0.22-1.el7.x86_64.rpm
- Execute commands in below sequence to install the mysql
rpm -ivh mysql-community-common-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.22-1.el7.x86_64.rpm
yum install openssl-devel openssl
rpm -ivh mysql-community-devel-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat-8.0.22-1.el7.x86_64.rpm
- By default mysql service is not started, start the service and check the status
[root@localhost mysql]# systemctl start mysqld
[root@localhost mysql]#
[root@localhost mysql]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-12-30 22:39:29 IST; 1min 32s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 6794 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 6877 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
└─6877 /usr/sbin/mysqld
Dec 30 22:39:21 localhost.localdomain systemd[1]: Starting MySQL Server...
Dec 30 22:39:29 localhost.localdomain systemd[1]: Started MySQL Server.
[root@localhost mysql]#
- By default the installation creates MySQL user and group. After the service is started it will initialize the data directory. For default data directory and log locations refer here.
- A superuser account
'root'@'localhost'
is created. A password for the superuser is set and stored in the error log file. Get the password to login to mysql
[root@localhost mysql]# sudo grep 'temporary password' /var/log/mysqld.log
2020-12-30T17:09:25.311493Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ************
- Login to mysql and change the password
[root@localhost mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
…………………
…………………
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '************';
Query OK, 0 rows affected (0.01 sec)
NOTE: validate_password
is installed by default. The default password policy implemented by validate_password
requires that passwords contain at least one uppercase letter, one lowercase letter, one digit, and one special character, and that the total password length is at least 8 characters.
This completes the installation of mysql. Happy learning.
Refer to mysql documentation for more information.