默认在CentOS上yum只能安装到MySQL5.7版本,所以要安装MySQL8需要额外的配置。
以安装MySQL8 Community Server为例
- 首先设置yum源
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
- 安装
MySQL的yum源里面有其他一些版本的MySQL,我们需要将其禁用,然后安装MySQL8 Community Server
sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo yum --enablerepo=mysql80-community install mysql-community-server
- 启动MySQL8,并设置开机启动
systemctl start mysqld systemctl enable mysqld
- 查看MySQL8首次启动生成的默认root密码,并修改密码
MySQL8首次启动会生成一个默认的root密码,我们可以查看/var/log/mysqld.log来找到这个默认密码
grep "A temporary password" /var/log/mysqld.log #[Note] A temporary password is generated for root@localhost: XXXYYY #我们用这个默认密码登录MySQL8 mysql -uroot -pXXXYYY alter user root@'localhost' identified by 'newpassword';
文章评论