CentOs7.3 安裝MySQL 8.0.12 RPM Bundle
一、移除舊MySQL
1、移除時執行以下删除指令
yum remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /var/lib/mysql
rm /etc/my.cnf
2、檢視是否還有殘留
如果仍然有,繼續删除即可.也可使用指令rpm -e –nodeps {-file-name} 移除。
二、安裝
1、下載下傳 MySQL 官網 https://www.mysql.com/downloads/ 選擇下載下傳社群版本(MySQL Community Edition (GPL)),我這裡下載下傳的是最新版本 mysql-8.0.12-1.el7.x86_64.rpm-bundle.tar。直接執行指令下載下傳全家桶
2、解壓
3、依次安裝
rpm -ivh mysql-community-common--el7.x86_64.rpm
rpm -ivh mysql-community-libs--el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat--el7.x86_64.rpm
rpm -ivh mysql-community-client--el7.x86_64.rpm
rpm -ivh mysql-community-devel--el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat--el7.x86_64.rpm
rpm -ivh mysql-community-test--el7.x86_64.rpm
rpm -ivh mysql-community-minimal-debuginfo--el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat--el7.x86_64.rpm
rpm -ivh mysql-community-server--el7.x86_64.rpm
rpm -ivh mysql-community-test--el7.x86_64.rpm
最後安裝的時候遇到一個錯誤
rpm -ivh mysql-community-embedded-compat--el7.x86_64.rpm
error: Failed dependencies:
libaio.so()(bit) is needed by MySQL-server-a-rhel5.x86_64
libaio.so(LIBAIO_0)(bit) is needed by MySQL-server-a-rhel5.x86_64
libaio.so(LIBAIO_0)(bit) is needed by MySQL-server-a-rhel5.x86_64
解決方法
yum install libaio
注: i-install安裝;v-verbose進度條;h-hash哈希校驗
4、檢視mysql 版本
5初始化MySQL
初始化完成後再下邊檔案末尾會有随機密碼,一會登陸時候用
[[email protected] ~]# cat /var/log/mysqld.log
--T05::Z [System] [MY-] [Server] /usr/sbin/mysqld (mysqld ) initializing of server in progress as process
--T05::Z [Note] [MY-] [Server] A temporary password is generated for [email protected]: ul8y;iZ)q28,
--T05::Z [System] [MY-] [Server] /usr/sbin/mysqld (mysqld ) initializing of server has completed
備注:如果需要設定大小寫敏感,一定要在初始化之前設定.
vim /etc/my.cnf
[mysqld]
default-authentication-plugin=mysql_native_password
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
`
lower_case_table_names = 1
`
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
5、啟動MySQL
啟動
停止
systemctl stop mysqld.service
重起
檢視狀态
6、登入MySQL并修改密碼
mysql -u root -p ul8y;iZ)q28,
alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.07 sec)
重新整理權限
FLUSH PRIVILEGES;
7、允許遠端通路
update user set host='%' where user='root';
Query OK, 1 row affected (0.11 sec)
Rows matched: 1 Changed: 1 Warnings: 0
8、将MySQL寫入開機啟動項
開機啟動
禁止開機啟動