看了兩三個教程。終于在嗶哩嗶哩找到一個簡單高效的教程,成功安裝,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)
安裝完成!