清华大学镜像 MySQL镜像 直接用的清华大学的
在Linux环境下踩了很多坑,看了很多教程,总算安装完成了,这篇文章来总结一下。
服务器买的是阿里云的服务器
我下载和解压的文件都放在根目录的mysql文件夹(新建的)里了。
1:下载MySQL
wget直接下载https文件可能会存在问题,所以前面加了--no-check-certificate
wget --no-check-certificate https://mirror.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-5.7.35-1.el6.x86_64.rpm-bundle.tar
2:mariadb是系统自带的需要清一下,不然会和mysql有冲突。
[root@ZhangShiHao mysql]# rpm -qa | grep mysql
[root@ZhangShiHao mysql]# rpm -qa | grep mariadb
mariadb-libs-5.5.65-1.el7.x86_64
[root@ZhangShiHao mysql]# rpm -e --nodeps mariadb-libs-5.5.65-1.el7.x86_64
3:加载MySQL安装包
[root@ZhangShiHao mysql]# tar -xvf mysql-5.7.35-1.el6.x86_64.rpm-bundle.tar
4,解压出来有很多,但是实际使用只有四个
mysql-community-devel-5.7.35-1.el6.x86_64.rpm
mysql-community-libs-5.7.35-1.el6.x86_64.rpm
mysql-community-test-5.7.35-1.el6.x86_64.rpm
mysql-community-client-5.7.35-1.el6.x86_64.rpm
mysql-community-embedded-5.7.35-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.35-1.el6.x86_64.rpm
mysql-community-common-5.7.35-1.el6.x86_64.rpm
mysql-community-embedded-devel-5.7.35-1.el6.x86_64.rpm
mysql-community-server-5.7.35-1.el6.x86_64.rpm
5:开始安装
5.1:前三个都没有什么问题
[root@ZhangShiHao mysql]# rpm -ivh mysql-community-common-5.7.35-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.35-1.el6.x86_64.rpm: Header V3 DSA/SHA256 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.35-1.e################################# [100%]
[root@ZhangShiHao mysql]# rpm -ivh mysql-community-libs-5.7.35-1.el6.x86_64.rpm
warning: mysql-community-libs-5.7.35-1.el6.x86_64.rpm: Header V3 DSA/SHA256 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.35-1.el6################################# [100%]
[root@ZhangShiHao mysql]# rpm -ivh mysql-community-client-5.7.35-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.35-1.el6.x86_64.rpm: Header V3 DSA/SHA256 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.35-1.e################################# [100%]
5.2安装mysql-community-server-5.7.35-1.el6.x86_64.rpm可能出现的问题
5.2.1:问题1
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.35-1.el6.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.35-1.el6.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.35-1.el6.x86_64
libsasl2.so.2()(64bit) is needed by mysql-community-server-5.7.35-1.el6.x86_64
解决方案
[root@ZhangShiHao mysql]# yum install libaio
5.2.2:问题2,在解决完问题1之后碰到的
error: Failed dependencies:
libsasl2.so.2()(64bit) is needed by mysql-community-server-5.7.35-1.el6.x86_64
解决方案
[root@ZhangShiHao mysql]# rpm -ivh mysql-community-server-5.7.35-1.el6.x86_64.rpm --force --nodeps
碰到这两个问题解决完成就可以启动服务了
6:开启服务
[root@ZhangShiHao mysql]# systemctl start mysqld
7:查看生成的密码,可以过滤,这里没有过滤直接查看所有了。
[root@ZhangShiHao mysql]# cat /var/log/mysqld.log
8:登录
[root@ZhangShiHao mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.35
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
9:修改一下配置文件
[root@ZhangShiHao mysql]# vim /etc/my.cnf
在这里加一句: validate_password=off
我也不知道对不对好像是验证密码关闭,这个配置文件可以搜一下全的补上去。
10:修改密码
mysql> alter user 'root'@'localhost' identified by '123456';
##修改好之后,就可以使用新密码登录了。
11:所有用户都可以链接
mysql> update user set host='%' where user = 'root';
##这样通过公网IP就可以链接了。
12:连接成功