Linux中MySQL安装教程
- Step1:卸载系统自带的mysql
- Step2:下载mysql8安装包
- Step3:上传mysql压缩包到 /opt 然后解压
- Step4:解压后按照如下顺序安装
- Step5:对mysql进行初始化
- Step6:修改mysql安装目录的所有用户和所属组
- Step7:查看mysql的临时密码
- Step8:登录mysql,并修改密码
Step1:卸载系统自带的mysql
检查 mariadb
rpm -qa | grep mariadb
卸载 mariadb(根据上面所查版本)
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
Step2:下载mysql8安装包
下载地址:https://downloads.mysql.com/archives/community/
Step3:上传mysql压缩包到 /opt 然后解压
cd /opt
mkdir java
cd java
tar -xvf mysql-8.0.34-1.el7.x86_64.rpm-bundle.tar
Step4:解压后按照如下顺序安装
rpm -ivh mysql-community-common-8.0.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.34-1.el7.x86_64.rpm
Step5:对mysql进行初始化
mysqld --initialize --console
Step6:修改mysql安装目录的所有用户和所属组
chown -R mysql:mysql /var/lib/mysql/
Step7:查看mysql的临时密码
cat /var/log/mysqld.log
Step8:登录mysql,并修改密码
mysql -uroot -p'这里填在mysqld.log中查看到的临时密码'
systemctl restart mysqld
systemctl status mysqld
alter user 'root'@'localhost' identified by 'wanchen1128';
完