CentOs下载MySQL
下载地址: https://downloads.mysql.com/archives/community/
通过FinallShall上传到虚拟机中,直接找到压缩包,往桌面一拖就行
创建文件夹放mysql
mkdir mysql
# 解压压缩包
tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar -C mysql
注意:CentOS下载软件需要root权限
su -
cd /home/主机名
由于CentOs可能自带了数据库,会与MySQL发生冲突所以先检查一下
rpm -qa|grep mariadb
如果有就删除掉
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
再切换到之前创建的mysql文件夹里面,可以看到
然后按照以下顺序进行下载,不要修改顺序
rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm
在执行下一条命令之前先下一个依赖不然会报错
yum install openssl-devel
rpm -ivh mysql-community-devel-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm
这样MySQL就按照好了
启动MySQL的服务
systemctl start mysqld
systemctl restart mysqld
systemctl stop mysqld
查阅临时密码
cat /var/log/mysqld.log
登录mysql
mysql -uroot -p
把密码修改简单
set global validate_password_length=4;
设置密码长度最低位数
set global validate_password_policy=LOW;
设置密码安全等级低,便于密码可以修改成1234
set password = password('1234');
lidate_password_policy=LOW;
设置密码安全等级低,便于密码可以修改成1234
set password = password(‘1234’);