软件在不断的进步,MySQL的版本也来到了8.0,下面介绍如何在centos 7上安装它。
下载MySQL仓库文件
访问官网,找到社区版本的MySQL下载页面,选择我们要下载的仓库文件。由于我们使用centos 7操作系统,则选择第二项下载。
上传文件,或通过命令下载到服务器上
#下载MySQL8.9仓库文件 wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
安装仓库文件
#安装仓库文件 rpm -ivh mysql80-community-release-el7-3.noarch.rpm #建立缓存 yum repolist yum makecache #yum安装MySQL8.0 yum -y mysql-community-server.x86_64
#安装成功后查询版本成功则正常安装 [root@google opt]# mysql -V mysql Ver 8.0.25 for Linux on x86_64 (MySQL Community Server - GPL) [root@google opt]# #启动MySQL8.0 systemctl start mysqld #设置开机自启动 systemctl enable mysqld
修改登录密码
执行以下命令,查询日志中的临时密码,如下面我的数据库临时密码为(仅为临时密码):ytYXGuVgJ7-y
#获取系统临时密码 [root@google opt]# grep 'password' /var/log/mysqld.log 2021-05-20T15:50:33.157635Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ytYXGuVgJ7-y [root@google opt]# #用此密码登录MySQL [root@google opt]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.25 Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> #修改密码策略 #修改自定义密码,我改为admin@123 #ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY "your_password"; mysql> set global validate_password.policy=0; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password.length=1; Query OK, 0 rows affected (0.01 sec) mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY "admin@123"; Query OK, 0 rows affected (0.01 sec)
至此新密码生效,安装完成,撒花!