centos安装mysql8.0教程

不废话,直接开始安装,环境自己检查,我使用的是centos7.6,已卸载所有关于mysql的环境

安装mysql源

rpm -Uvh https://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm

开始安装

yum --enablerepo=mysql80-community install mysql-community-server

如果环境很多依赖包没有,我的环境大概有500多M

启动mysql服务

systemctl start mysqld && systemctl enable mysqld

查看生成的默认密码

[root@localhost ~]# cat /var/log/mysqld.log |grep password
2021-11-26T08:37:53.711596Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: p4fZva#b%t)8

默认生成的root密码是:p4fZva#b%t)8

初始化数据库

[root@localhost ~]# mysql_secure_installation 

Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password: 
 ... Failed! Error: Your password does not satisfy the current policy requirements

New password: 

Re-enter new password: 
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) : yes

New password: 

Re-enter new password: 
Sorry, passwords do not match.

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) : yes
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) : yes
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) : y
Success.

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! 

我的新密码设置的是:CNBUGS.com1126

如果设置太简单后面还会有很多问题的哦

使用新密码登录数据库

成功登录到mysql里边啦,大功告成

安装过程中有什么问题欢迎随时留言。

来张美图镇楼!!!

发表评论

登录... 后才能评论