目录
1.下载安装文件
2.上传到CentOS7上
3.解压MySQL文件
4.清理系统中残留的MySQL
5.安装MySQL
6.启动MySQL 并 设置开机自启动
7.查找临时密码,并修改密码
注意:
教程:在Linux上安装mysql(超详细版)_哔哩哔哩_bilibili
1.下载安装文件
网址:MySQL
2.上传到CentOS7上
创建文件夹
[root@localhost ~]# cd /opt/
[root@localhost opt]# mkdir software
上传文件
3.解压MySQL文件
[root@localhost software]# tar -xvf mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar
4.清理系统中残留的MySQL
查找残留文件
[root@localhost software]# rpm -qa| grep -i mariadb
[root@localhost software]# rpm -qa| grep -i mysql
[root@localhost software]# find / -name mysql
删除残留文件
[root@localhost software]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
[root@localhost software]# rm -rf /etc/selinux/targeted/active/modules/100/mysql
[root@localhost software]# rm -rf /usr/lib64/mysql
5.安装MySQL
[root@localhost software]# rpm -ivh mysql-community-common-5.7.38-1.el7.x86_64.rpm
[root@localhost software]# rpm -ivh mysql-community-libs-5.7.38-1.el7.x86_64.rpm
[root@localhost software]# rpm -ivh mysql-community-client-5.7.38-1.el7.x86_64.rpm
[root@localhost software]# rpm -ivh mysql-community-server-5.7.38-1.el7.x86_64.rpm
如果你在最后一个遇到问题,记得安装 net-tools
[root@localhost software]# yum install net-tools
6.启动MySQL 并 设置开机自启动
[root@localhost software]# systemctl start mysqld
[root@localhost software]# systemctl enable mysqld
[root@localhost software]# systemctl status mysqld
7.查找临时密码,并修改密码
[root@localhost software]# cat /var/log/mysqld.log | grep password
[root@localhost software]# mysql -uroot -p
mysql> set password = password("Aa@12345678")
-> ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> exit;
Bye
注意:
密码格式:
- 至少8个字符
- 包含数字
- 大小写字母
- 特殊字符