目录
下载官网:MySQL :: Download MySQL Community Server (Archived Versions)
使用ftp工具上传到虚机:
解压到/usr/local/mysql 目录下:
- [root@sql ~]# mkdir -p /usr/local/mysql
- [root@sql ~]# tar -xvf mysql-8.0.30-1.el7.x86_64.rpm-bundle.tar -C /usr/local/mysql/
- [root@sql ~]# cd /usr/local/mysql/
- [root@sql mysql]# ls
-
- # 安装依赖
- [root@sql mysql]# rpm -ivh mysql-community-common-8.0.30-1.el7.x86_64.rpm
- [root@sql mysql]# rpm -ivh mysql-community-client-plugins-8.0.30-1.el7.x86_64.rpm
- [root@sql mysql]# yum remove -y mysql-libs
- [root@sql mysql]# rpm -ivh mysql-community-libs-8.0.30-1.el7.x86_64.rpm
- [root@sql mysql]# rpm -ivh mysql-community-libs-compat-8.0.30-1.el7.x86_64.rpm
- [root@sql mysql]# yum install -y openssl-devel
- [root@sql mysql]# rpm -ivh mysql-community-devel-8.0.30-1.el7.x86_64.rpm
- [root@sql mysql]# rpm -ivh mysql-community-debuginfo-8.0.30-1.el7.x86_64.rpm
- [root@sql mysql]# rpm -ivh mysql-community-embedded-compat-8.0.30-1.el7.x86_64.rpm
- [root@sql mysql]# rpm -ivh mysql-community-icu-data-files-8.0.30-1.el7.x86_64.rpm
-
- # 安装服务
- [root@sql mysql]# rpm -ivh mysql-community-client-8.0.30-1.el7.x86_64.rpm
- [root@sql mysql]# rpm -ivh mysql-community-server-8.0.30-1.el7.x86_64.rpm
- [root@sql mysql]# rpm -ivh mysql-community-server-debug-8.0.30-1.el7.x86_64.rpm
- [root@sql mysql]# yum install perl-JSON perl-Test-Simple perl-Data-Dumper -y
- [root@sql mysql]# rpm -ivh mysql-community-test-8.0.30-1.el7.x86_64.rpm
如遇这种错误,则执行 yum remove -y mysql-libs:
- systemctl start mysqld.service # 启动mysql
- systemctl stop mysqld.service # 停止mysql
- systemctl status mysqld.service # 查看服务状态
- [root@sql mysql]# grep 'temporary password' /var/log/mysqld.log
- 2022-10-27T09:55:06.713260Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: sohqQe?%&6LC
-
- # sohqQe?%&6LC 就是随机生成的 root 密码
-
- # 复制密码登录 mysql
- [root@sql mysql]# mysql -uroot -p
- Enter password:
MySQL密码设置规则官网:MySQL :: MySQL 8.0 Reference Manual :: 6.4.3.2 Password Validation Options and Variables
登录到MySQL之后,需要将自动生成的不便记忆的密码修改了,修改成自己熟悉的便于记忆的密码。密码设置默认需要满足长度至少8位,数字、大/小写和特殊字符。
- alter user 'root'@'localhost' identified by '你的密码';
-
- # 如果你要降低密码复制程度,可以先设置符合规则的密码,再输入下面的语句
- set global validate_password.policy = 0;
- set global validate_password.length = 4;
- ALTER USER 'root'@'localhost' IDENTIFIED BY '1234';
可以看我这篇文章:MySQL 常见问题汇总(持续更新)_Stars.Sky的博客-CSDN博客_mysql常见问题
通过连接工具即可远程连接 MySQL。
- #1. 停止MySQL服务
- systemctl stop mysqld
-
- #2. 查询MySQL的安装文件
- rpm -qa | grep -i mysql
-
- #3. 卸载上述查询出来的所有的MySQL安装包
- rpm -e --nodeps mysql-x.x.x.x
-
- #4. 删除MySQL的数据存放目录
- rm -rf /var/lib/mysql/
-
- #5. 删除MySQL的配置文件备份
- rm -rf /etc/my.cnf.rpmsave