MySQL 8.0.16 installation full version tutorial under CentOS

MySQL 8.0.16 installation full version tutorial under CentOS


1. Download the installation package

Since the download process is slow, download and prepare the installation package locally first.

MySQL 8.0 download link (official website address):

https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar

Note: The corresponding version of CentOS is the Red Hat version.

2. Clean up old versions

Check whether there is an existing mysql package locally:

rpm -qa | grep mysql

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-19LrpJGC-1611231213212)(evernotecid://6FE75482-54A0-433A-9625-A01F7FEE92EC/appyinxiangcom/9896050/ENResource /p3141)]

If there is a MySQL version, use the command rpm -e --nodeps {-file-name} to remove it:

//示例:
rpm -e --nodeps mysql-community-libs-8.0.22-1.el7.x86_64

Find related directories:

find / -name mysql

Delete related directories:

rm -rf /var/lib/mysql
……

At this time, complete the cleanup of the old MySQL. If it is the first installation, skip this step.

3. Install mysql 8.0.16

Upload the installation package to the CentOS server. My upload directory is: /usr/local/mysql.

Enter the installation package directory:

cd /usr/local/mysql

Unzip the installation package:

tar -xvf mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar

Install in order:

rpm -ivh mysql-community-common-8.0.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.22-1.el7.x86_64.rpm  --force --nodeps
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  --force --nodeps
rpm -ivh mysql-community-server-8.0.22-1.el7.x86_64.rpm  --force --nodeps

After the installation is complete, check:

rpm -qa | grep mysql

4. Start MySQL

  • Start the service:
systemctl start mysqld
  • View service status:
systemctl status mysqld.service

5. Set login password

  • Query the default temporary password:
cat /var/log/mysqld.log | grep password
  • Log in to the MySQL service:
mysql -uroot -p

Enter the default temporary password here.

  • Before changing the password, you must set the password registration, otherwise the password setting is too simple and it will fail:
# 密码检查等级,0/LOW、1/MEDIUM、2/STRONG
set global validate_password.policy=0;
# 密码的最短长度
set global validate_password.length=6;
# 密码至少要包含的小写字母个数和大写字母个数
set global validate_password.mixed_case_count=0;
  • change the password:
# 设置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your password';

6. Modify login permissions

Modify remote login permissions

USE mysql;
UPDATE mysql.user SET host = '%' WHERE user = 'root';
flush privileges;
SELECT host, user FROM user;

Ok, MySQL has been installed and can be used next.


PS: For more more content..., please check --> "Server Development"
PS: More more content..., please check --> "Server Development"
PS: More more content..., please check --> "Server Development"

Guess you like

Origin blog.csdn.net/u011578734/article/details/112971214