看了两三个教程。终于在哔哩哔哩找到一个简单高效的教程,成功安装,up主名叫bili逍遥bili,感兴趣可以去看看。下面这个是我总结的安装方法
1.下载安装包,个人觉得在虚拟机里面下载安装包会比较方便且不易出错。
[root@localhost /]# wget https://cdn.MySQL.com//Downloads/MySQL-5.6/mysql-5.6.50-linux-glibc2.12-x86_64.tar.gz

2.解压
[root@localhost /]# tar -zxf mysql-5.6.50-linux-glibc2.12-x86_64.tar.gz
[root@localhost /]# cd
3.创建特殊的账号
[root@localhost ~]# useradd -r -s /sbin/nologin mysql

[root@localhost ~]# cd ..
4.移动文件到/usr/local/mysql目录下
[root@localhost /]# mv mysql-5.6.50-linux-glibc2.12-x86_64 /usr/local/mysql

5.更改目录权限
[root@localhost /]# chown -R mysql.mysql /usr/local/mysql
[root@localhost /]# ll /usr/local/mysql

6.初始化数据库,若出现ERROR,需要安装autoconf
[root@localhost /]# /usr/local/mysql/scripts/mysql_install_db --user=mysql

[root@localhost mysql]# yum -y install autoconf

7.注意,已进入MySQL目录下,重试初始化命令
[root@localhost mysql]# scripts/mysql_install_db --user=mysql


[root@localhost mysql]# ll data
8.移除mariadb-libs库文件,因为安装mysql的话会和mariadb的文件冲突。
[root@localhost mysql]# yum remove mariadb-libs

9.再次重试初始化命令
[root@localhost mysql]# scripts/mysql_install_db --user=mysql

[root@localhost mysql]# ll data

10.移动mysql.server 到init.d目录
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql
启动MySQL服务
[root@localhost mysql]# service mysql start
Starting MySQL.Logging to '/usr/local/mysql/data/192.168.15.129.err'.
............ SUCCESS!

11.设置密码
这里把密码设置为‘123’
[root@localhost mysql]# bin/mysqladmin -u root password '123'
12.连接到 MySQL 服务器
[root@localhost mysql]# bin/mysql -uroot -p

mysql> create database firstdb;
Query OK, 1 row affected (2.56 sec)

安装完成!