1、下载安装 MySQL Yum 仓库
请按照自己不同的系统执行以下命令下载安装 MySQL Yum 仓库:
CentOS 8
- wget https://repo.mysql.com/mysql80-community-release-el8-1.noarch.rpm
- yum localinstall mysql80-community-release-el8-1.noarch.rpm
CentOS 7
- wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
- yum localinstall mysql80-community-release-el7-1.noarch.rpm
CentOS 6
- wget https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm
- yum localinstall mysql80-community-release-el6-1.noarch.rpm
2. 安装 MySQL 8 社区服务器
执行以下命令安装 MySQL 8:
yum install mysql-community-server -y
3. 启动 MySQL 服务
根据自己不同的系统版本使用以下命令启动 mysql 服务:
CentOS 8 或 CentOS 7
systemctl start mysql
CentOS 6
service mysqld start
4. 显示 root 用户的默认密码
安装 MySQL 8.0 时,会自动为 root 用户生成一个临时密码,并记录在日志文件里。请使用以下命令查看 root 用户的临时密码:
grep "A temporary password" /var/log/mysqld.log
这是输出:
[Note] A temporary password is generated for root@localhost: Liaka*(Dka&