Home>Article>Operation and Maintenance> centos7 mysql8.0 installation method

centos7 mysql8.0 installation method

藏色散人
藏色散人 Original
2020-11-06 10:06:59 10676browse

centos7 Mysql8.0 installation method: First uninstall the historical version of MySQL; then use the command "sudo yum install mysql-server" to install MySQL; finally set it to start at boot.

centos7 mysql8.0 installation method

Recommendation: "centos tutorial"

CentOS 7 Installation of MySQL8.0

1. Uninstall the historical version of MySQL

Check whether you have the historical version

If you are not installing for the first time, you need to uninstall the historical version of MySQL. Use the command to check whether the historical version of MySQL component is installed

# rpm -qa|grep mysql

centos7 mysql8.0 installation method

For example, two installed MySQL Community Edition components are queried in the picture. Before installing the new version of MySQL, you need to remove the installed historical components

Check the MySQL service status

# service mysqld status

Pause the MySQL service

# service mysqld stop

Uninstall the MySQL service

You need to remove all components. Please note that there may be dependencies in the order of components.

# rpm -ev [需要移除组件的名称]

or

# rpm -e --nodeps [需要移除组件的名称] //此命令为强制卸载

2. Install MySQL

Use rpm to install MySQL

Because the default database installed by CentOS 7 is Mariadb, use the YUM command MySQL cannot be installed, only Mariadb will be updated. Use rpm to install. You can right-click the mysql repo source warehouse to copy the specified version of the database.

# wget http://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm

Install the mysql80-community-release-el7-1.noarch.rpm package

# sudo rpm -ivh mysql80-community-release-el7-1.noarch.rpm

After the installation is completed, two files will be obtained in the /etc/yum.repos.d folder: mysql-community.repo && mysql-community-source.repo

centos7 mysql8.0 installation method

##Use yum to install the mysql service

# sudo yum install mysql-server

If the following content is displayed, the installation is successful

Complete!

Check whether it has been set to start the MySQL service at boot

# systemctl list-unit-files|grep mysqld

If

centos7 mysql8.0 installation method

is displayed, it means that it has been set to start at boot. If it is not set to start at boot If it is started, execute

# systemctl enable mysqld.service

Check if MySQL is started. If it is not started, execute the start service command

Check if the MySQL service is started

# ps -ef|grep mysql

Start the service

# systemctl start mysqld.service

Initialize MySQL

# mysqld --initialize

View MySQL initial default password

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

centos7 mysql8.0 installation method

Copy the password behind root@localhost:. Log in to mysql and paste the default password

Because of the changes in MySQL8.0, the password must be reset

alter user 'root'@'localhost' identified by '12345678';

If a prompt appears when setting the password

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

It means you need to lower the policy level before executing

set global validate_password.policy=0;

Open the MySQL remote connection

use mysql; #修改root账户权限 update user set host = '%' where user = 'root'; #刷新权限 flush privileges;

The above is the detailed content of centos7 mysql8.0 installation method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn