去官网找到自己要安装的mysql版本,网址:https://dev.mysql.com/downloads/mysql/
找到对应版本,复制下载链接
然后用wget进行安装:
mkdir mysql
cd mysql
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.22-1.el8.x86_64.rpm-bundle.tar
下载完成后,使用tar命令进行解压,解压出来是散的,所以需要提前新建一个文件夹
tar -xvf mysql-8.0.22-1.el8.x86_64.rpm-bundle.tar
安装步骤,以下需要按顺序进行安装
# 安装依赖
yum install libaio net-tools perl
yum install perl-JSON.noarch -y
# 按顺序安装mysql的各个组件(需要按顺序安装,否则会安装失败)
rpm -ivh mysql-community-common-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-debugsource-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debug-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-plugins-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-test-debuginfo-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-debug-8.0.22-1.el8.x86_64.rpm
rpm -ivh mysql-community-test-8.0.22-1.el8.x86_64.rpm
如果出现错误可以根据日志内容来判断,如:
https://blog.csdn.net/aiyowei1106/article/details/88703746
如果没有启动使用cat来查看日志
cat /var/log/mysqld/log
查看服务是否启动
service mysqld status
正常启动的情况显示这样
查看mysql初始密码:
grep 'temporary password' /var/log/mysqld.log
初始密码是最后面那个YZxd-*)q720J
进入mysql
mysql -u root -p
YZxd-*)q720J
修改密码
set password for 'root'@'localhost' = password('root123');
现在就可以正常使用了...