MySQL 8.0.16 installation and configuration tutorial under CentOS7

MySQL 8.0.16 installation and configuration tutorial under CentOS7

Uninstall the old version of MySQL (skip this step if you don’t have one)

( Note: When reinstalling a new version of MySQL in steps 3-6, be sure to uninstall the previous version completely to avoid errors; when installing MySQL for the first time on a new virtual machine, only steps 1-2 are required)

1. View old versions of MySQL

rpm -qa | grep mysql

2. Delete old components one by one

Use the rpm -e --nodeps {-file-name} command to remove the files. There may be dependencies when removing the files, so pay attention to the order.

After deleting, check to see if there are any old versions.

3.rm -rf /var/lib/mysql
rm /etc/my.cnf

4.find / -name mysql

Clear all directories and files related to MySQL and other configurations and settings. If so, delete it. It is also necessary to consider that other software will not be affected.

rm -rf /usr/lib/mysql
rm -rf /usr/share/mysqlwhereis mysql

6. Self-starting service

chkconfig --list | grep -i mysql
chkconfig --del mysqld

Install MySQL

1. Upload the MySQL installation package to the /usr/local/mysql/ folder on centos

insert image description here

2. Enter /usr/local/mysql/

3. Start installing MySQL

Run the rpm -ivh {-file-name} command to perform the installation operation.
Install the rpm packages in order according to the dependencies: common→libs→client→server
Note: In ivh, i-install installation; v-verbose progress bar; h-hash hash verification

rpm -ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm

Solution to errors when installing libs;

Clear all mysql dependency packages in yum yum remove mysql-libs

4. Installation successful

5. Start mysql

After installation, start the MySQL service using the command: (If the mysql service cannot be started, restart the system)

systemctl start mysqld.service (service mysqld start) starts mysql
systemctl status mysqld.service (service mysqld status) View mysql status systemctl stop mysqld.service (service mysqld stop) Shut down mysql

6. Change MySQL password

First use the following command to find the password:

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

Login to mysql with password

mysql -uroot -p

To change your password:

alter user root@localhost identified by 'your password'; 

insert image description here

(Note that the password here should be as complex as possible, otherwise it will fail (ERROR 1819 (HY000): Your password does not satisfy the current policy requirements)

(If you want to make the password simpler, you need to execute the following two commands first:
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1; )


7. Login

mysql -uroot -p

8. Check the mysql process ps -ef | grep mysql

9. Check port 3306 netstat -anop | grep 3306

10. Grant remote access to the root user

1) use mysql;

2) select user, host from user;

3) update user set host='%' where user = 'root';

4) grant all privileges on . to 'root'@'%' identified by 'tsk007' with grant option;

5) flush privileges;

insert image description here

11.systemctl stop firewalld.service (turn off the firewall)
systemctl disable firewalld.service (turn off the firewall at boot)

12. Remote login (MySQL must be installed on this machine)

mysql -uroot -p -h (accessed IP)

Reference article: How to completely uninstall MySQL under CentOS

Wonderful topic sharing:

MySQL different versions installation tutorial

MySQL 5.7 installation tutorials for various versions

MySQL 5.6 installation tutorials for various versions

mysql8.0 installation tutorials for various versions

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed steps to install MYSQL8.0 on CentOS7.6
  • Tutorial on installing MySQL 5.7.28 on CentOS 6.2 (mysql notes)
  • Detailed tutorial on installing mysql 8.0.13 (rpm) on Centos7
  • CentOS7 uses yum to install mysql 8.0.12
  • Detailed steps for installing and configuring MySQL 8.0 on CentOS
  • CentOS7 installation GUI interface and remote connection implementation
  • Tutorial on installing MySql5.7 in CentOS7.2 and enabling remote connection authorization
  • Reasons and solutions for being unable to remotely connect to MySQL database under CentOS7
  • How to install MySql in CentOS 8 and allow remote connections

<<:  Specific use of Bootstrap5 breakpoints and containers

>>:  Docker uses the mysqldump command to back up and export mysql data in the project

Recommend

How to deploy code-server using docker

Pull the image # docker pull codercom/code-server...

Nginx 502 Bad Gateway Error Causes and Solutions

I have encountered the Nginx 502 Bad Gateway erro...

Vue implements two routing permission control methods

Table of contents Method 1: Routing meta informat...

A simple method to regularly delete expired data records in MySQL

1. After connecting and logging in to MySQL, firs...

Detailed explanation of the execution process of MySQL query statements

Table of contents 1. Communication method between...

CSS eight eye-catching HOVER effect sample code

1. Send effect HTML <div id="send-btn&quo...

Example code for implementing transparent gradient effects with CSS

The title images on Zhihu Discovery columns are g...

How to install PostgreSQL and PostGIS using yum on CentOS7

1. Update the yum source The PostgreSQL version o...

MySQL sharding details

1. Business scenario introduction Suppose there i...

An article to give you a deep understanding of Mysql triggers

Table of contents 1. When inserting or modifying ...

Explanation of several ways to run Tomcat under Linux

Starting and shutting down Tomcat under Linux In ...