yum安装mysql 8.0

Posted 雅冰石

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了yum安装mysql 8.0相关的知识,希望对你有一定的参考价值。

一 安装mysql 8.0 yum源

cd /etc/yum.repos.d/

curl https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm > centos7.mysql.rpm

yum install centos7.mysql.rpm -y

 看到/etc/yum.repo.d目录下生产了以下两个文件:

-rw-r--r--  1 root root  2108 Apr 25  2019 mysql-community-source.repo

-rw-r--r--  1 root root  2076 Apr 25  2019 mysql-community.repo

#修改mysql 8.0镜像,关闭强制认证

vi mysql-community.repo

 二 yum安装mysql

/*

#查看下列文件的属性,确保没有输出i属性

lsattr /etc/passwd

lsattr /etc/group

lsattr /etc/shadow

lsattr /etc/gshadow

 假如有i属性,那在后面执行yum install mysql-community-server -y时会无法自动建mysql用户,会报错:

warning: user mysql does not exist - using root

后面Mysql也起不来,执行journalctl -xe报错:

Mar 18 17:44:23 Centos7-Mode-V8 systemd[25239]: Failed at step USER spawning /usr/bin/mysqld_pre_systemd: No such process

-- Subject: Process /usr/bin/mysqld_pre_systemd could not be executed

需要去除i属性:

chattr -ia /etc/passwd

chattr -ia /etc/group

chattr -ia /etc/shadow

chattr -ia /etc/gshadow

*/

yum install mysql-community-server -y

三 启动mysql

systemctl start mysqld

systemctl enable mysqld

#检查启动状态

systemctl status mysqld

查看root临时密码

安装完mysql之后,会生成一个临时的密码让root用户登录

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

 安全操作

[root@Centos7-Mode-V8 system]# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:

The 'validate_password' component is installed on the server.

The subsequent steps will run with the existing configuration

of the component.

Using existing password for root.

Estimated strength of the password: 100

Change the password for root ? ((Press y|Y for Yes, any other key for No) : Y

New password:

Re-enter new password:

Estimated strength of the password: 100

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them. This is intended only for

testing, and to make the installation go a bit smoother.

You should remove them before moving into a production

environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Success.

Normally, root should only be allowed to connect from

'localhost'. This ensures that someone cannot guess at

the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 ... skipping.

By default, MySQL comes with a database named 'test' that

anyone can access. This is also intended only for testing,

and should be removed before moving into a production

environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

 - Dropping test database...

Success.

 - Removing privileges on test database...

Success.

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Success.

All done!
本篇文章参考自:

MySQL :: MySQL 8.0 Reference Manual :: 2.5.1 Installing MySQL on Linux Using the MySQL Yum Repository

以上是关于yum安装mysql 8.0的主要内容,如果未能解决你的问题,请参考以下文章

yum安装mysql 8.0

在 CentOS 7 上 yum 安装 MYSQL 8.0

Linux下的 Mysql 8.0 yum 安装 并修改密码

centos 7下安装mysql-8.0

安装MySQL

安装MYSQL 8.0