【Linux】【MySQL】 CentOS 安裝MySQL 8.0

第一步: 下載 rpm 安裝包 

卸載 mariadb
# 查看 mariadb 的安裝包
rpm -qa | grep mariadb
# 卸載 mariadb 的安裝包
rpm -e  mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
# 再次查看
rpm -qa | grep mariadb

 

我這裏使用 wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm 的方式。

當然也可以使用SFTP, 或者 直接在Linux的GUI界面的瀏覽器下載, 或者使用 scp 命令從 windows拷入到虛擬機。

第二步: 安裝 rpm 包

sudo rpm -Uvh  mysql80-community-release-el7-3.noarch.rpm

這裏安裝包的名字 根據第一步下載的文件名來,版本可能會更新。

yum install mysql-community-server

根據官方文檔,以及我的測試,這一步會自動把系統安裝過的mariaDB 或者別的版本的mysql卸載掉。

不需要再安裝流程前,把所有類似的軟件全部卸載光光,很省力。

自動就卸載了mariaDB

第三步: 打開服務

sudo systemctl start mysqld.service        // 打開服務

sudo systemctl status mysqld.service     // 查看狀態

第四步:獲取初始密碼

A superuser account 'root'@'localhost is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:

shell> sudo grep 'temporary password' /var/log/mysqld.log

Change the root password as soon as possible by logging in with the generated, temporary password and set a custom password for the superuser account:

shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章