Loading... # 引言 开发三部曲,前端后端数据库,部署开发环境也是不能或缺的,俗话说不会安装环境的程序员不是好开发。 # 第一步,下载mysql数据库 废话不多说,直接上地址:https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar # 第二部,上传到服务器 如果使用wget 或者其它命令下载的服务器上了就不用这一步了。 如果目标主机为虚拟机或者远程终端,是由ftp或者scp传一下吧。 # 第三步,解压 ```bash tar -xf mysql-8.0.20-1.el7.x86_64.rpm-bundle ``` 随后通过`ll`命令,你会看到。 ![image.png](https://www.zunmx.top/usr/uploads/2022/04/705013512.png) # 第四步,安装 ```bash rpm -ivh mysql-community-common-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-embedded-compat-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-devel-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-test-8.0.20-1.el7.x86_64.rpm ``` ## 可能遇到的问题 在安装MySQL之前,我也安装了部分依赖,实际操作中可能不止这些,当然也可能不会遇到这些问题。 ```bash perl(Data::Dumper) is needed by mysql-community-test-8.0.20-1.el7.x86_64 perl(JSON) is needed by mysql-community-test-8.0.20-1.el7.x86_64 ``` <div class="tip inlineBlock share"> 解决方案: ```bash yum install perl.x86_64 perl-devel.x86_64 perl-JSON.noarch -y ``` </div> ```bash error: Failed dependencies: pkgconfig(openssl) is needed by mysql-community-devel-8.0.20-1.el7.x86_64 ``` <div class="tip inlineBlock share"> 解决方案: ```bash yum install openssl-devel.x86_64 openssl.x86_64 -y ``` </div> # 启动MySQL服务 ```bash service mysqld start ``` # 查看数据库密码 ```bash cat /var/log/mysqld.log ``` ![image.png](https://www.zunmx.top/usr/uploads/2022/04/102492847.png) # 修改MySQL密码 如果你想设置弱口令,需要执行: ```mysql set global validate_password.policy=low; ``` ```mysql alter USER 'root'@'localhost' IDENTIFIED BY 'new password'; ``` <div class="tip inlineBlock info"> 此处的new password 是新密码 </div> © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏