CentOS7.9使用yum方式安裝mysql8.0.27(2022最新版)
1.安裝說明
yum方式安裝MySQL數據庫比rpm安裝要簡單很多, yum方式的安裝原理是在執行yum安裝命令后,會自動從yum源地址下載相應名稱的MySQL數據庫rpm包,然后到系統上安裝,並自動解決各種軟件包之間的依賴問題。這是一個非常不錯的安裝軟件的方式,不僅僅是針對MySQL,安裝其他軟件也是如此。
Yum安裝方式的最大優點就是超級簡單,但是它也有自身的問題,例如它繼承了rpm包的無法定制化安裝的問題,另外一個缺點是采用默認的yum安裝時,無法安裝mysql,因為CentOS7開始已經在官方庫把默認的mysql換成了開源的mariadb了。如果要用yum方式安裝mysql,必須先下載安裝MySQL源才行。
#1)關閉selinux:
setenforce 0
getenforce
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
2.卸載mariadb依賴包
[root@oldboy ~]# rpm -qa|grep mariadb #<==查找已經安裝的mariadb的包。
mariadb-libs-5.5.68-1.el7.x86_64
[root@oldboy ~]# yum remove mariadb-libs -y #<==卸載系統已經安裝的mariadb依賴包。
3.下載mysql安裝源
在MySQL官網中下載YUM源rpm安裝包:https://dev.mysql.com/downloads/repo/yum/ 或者直接執行下面命令
[root@oldboy ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
[root@oldboy opt]# rpm -ivh mysql80-community-release-el7-11.noarch.rpm
4.查看安裝的mysql源
[root@oldboy opt]# rpm -ql mysql80-community-release
/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
/etc/yum.repos.d/mysql-community-source.repo
/etc/yum.repos.d/mysql-community.repo
5.開始安裝mysql
yum install mysql-community-server -y
6.啟動mysql服務,並檢查啟動狀態
mysqld --initialize-insecure --user=mysql
systemctl start mysqld
[root@oldboy ~]# netstat -lntup|grep 330
tcp6 0 0 :::33060 :::* LISTEN 3267/mysqld
tcp6 0 0 :::3306 :::* LISTEN 3267/mysqld
7.登錄測試
[root@oldboy lib]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.27 MySQL Community Server - GPL
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
8.安裝FAQ
如果出現安裝問題:
1.看日志/var/log/mysqld.log
2.selinux問題,執行setenforce 0臨時關閉看看。
3.登錄不進去
[root@oldboy ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
辦法:
systemctl stop mysqld
rm -fr /var/lib/mysql/
mysqld --initialize-insecure --user=mysql
systemctl start mysqld
mysql
CentOS7.9使用rpm方式安裝mysql8.0.26(2022最新版)
https://www.cnblogs.com/oldboy666/p/15558992.html