1. 在使用阿里云ECS进行ssh时【使用ssh客户端连接阿里云服务器】,只要稍稍过一段时间不操作就会自动断开连接,输入以下命令,解决办法如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@shaoin ~]# vim /etc/ssh/sshd_config

找到以下两项配置[默认情况下,此两项是注释掉的]:
#ClientAliveInterval 0
#ClientAliveCountMax 3

将其修改为:
ClientAliveInterval 30
ClientAliveCountMax 86400

具体含义:
1、客户端每隔多少秒向服务发送一个心跳数据,30
2、客户端多少秒没有相应,服务器自动断掉连接,配置的是24小时

:wq退出
  1. https://downloads.mysql.com/archives/community/ 下载MySQL安装包;
1
2
3
4
5
product version:选择版本;

operating System:操作系统; 选择Red Hat Enterprise Linux / Oracle Linux

OS Version:版本;选择all
  1. 将下载的包放到服务器/root目录下;再执行解压指令;
1
[root@shaoin ~]# tar -xvf mysql.xx.xx.xx-x.elxx.x86_64.rpm.bundle.tar;
  1. 删除服务器上自带的mariadb
1
2
[root@shaoin ~]# rpm -qa|grep mariadb;
[root@shaoin ~]# rpm -e --nodeps mariadb-libs;
  1. 按顺序安装MySQL的相关文件
1
2
3
4
5
6
[root@shaoin ~]# rpm -ivh mysql-community-common-xxxx-xxxx-xxx-xxx-xxx;
[root@shaoin ~]# rpm -ivh mysql-community-client-plugins-xxxx-xxxx-xxx-xxx-xxx;
[root@shaoin ~]# rpm -ivh mysql-mysql-community-libs-xxxx-xxxx-xxx-xxx-xxx;
[root@shaoin ~]# rpm -ivh mysql-mysql-community-client-xxxx-xxxx-xxx-xxx-xxx;
[root@shaoin ~]# rpm -ivh mysql-mysql-community-icu-data-files-xxxx-xxxx-xxx-xxx-xxx;
[root@shaoin ~]# rpm -ivh mysql-mysql-community-serve-xxxx-xxxx-xxx-xxx-xxx;
  1. 关于libaio报错安装
1
[root@shaoin ~]# yum -y install libaio;		//安装libaio包 再去安装报错的指令;
  1. 初始化MySQL
1
2
3
4
5
6
[root@shaoin ~]# mysqld --initialize --console;
[root@shaoin ~]# chown -R mysql:mysql /var/lib/mysql/
[root@shaoin ~]# systemctl start mysqld
[root@shaoin ~]# cat /var/log/mysqld.log|grep localhost // 查询初始默认密码;
[root@shaoin ~]# mysql -uroot -p
Enter password: //输入默认密码
  1. 修改密码
1
2
3
4
5
6
mysql> alter user 'root'@'localhost' identified by '123456';
mysql> exit;
[root@shaoin ~]# mysql -uroot -p
Enter password: //输入123456
mysql> show databases;
mysql> exit;