CentOS7系列--使用yum安裝MySQL8.0
本文主要涉及mysql8.0的yum安裝以及修改密碼
一、yum安裝mysql
cd /usr/local/src/ # 下載mysql80的rpm倉庫源 wget https://repo.mysql.com/mysql80-community-release-el7.rpm # 安裝mysql8.0源 yum -y install ./mysql80-community-release-el7.rpm # yum makecache fast #查看正在使用的MySQL repo yum repolist all|grep mysql # 安裝MySQL80 yum install -y mysql-community-common mysql-community-libs mysql-community-libs-compat mysql-community-client mysql-community-server # 設置 mysql 開機啟動 systemctl enable mysqld # 啟動mysql systemctl start mysqld
二、登錄mysql 并修改密碼
初始安裝mysql的密碼保存在/var/log/mysqld.log中,使用命令查找密碼如下:
~]# grep password /var/log/mysqld.log 2021-04-24T00:05:59.134760Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: vvlJb:iSx4?6
密碼就在行末尾,使用此密碼即可登錄mysql,不過不安全,需要自行修改密碼,修改命令如下:
mysqladmin -u root password Dear@123456! -p vvlJb:iSx4?6
當然,也可以登錄之后,使用alter命令進行修改:
alter user root@localhost identified by 'Dear@123456!';
至此mysql安裝完成。
三、記錄一個安裝啟動時候的報錯
安裝完成,使用命令啟動時,發現啟動失敗,使用命令“journalctl -xe”查看失敗原因如下:
my.cnf.d]# journalctl -xe Apr 24 08:33:16 hw-1-8 mariadbd[13864]: 2021-04-24 8:33:16 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. Apr 24 08:33:16 hw-1-8 mariadbd[13864]: 2021-04-24 8:33:16 0 [Note] Plugin 'FEEDBACK' is disabled. Apr 24 08:33:16 hw-1-8 mariadbd[13864]: 2021-04-24 8:33:16 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Apr 24 08:33:16 hw-1-8 mariadbd[13864]: 2021-04-24 8:33:16 0 [ERROR] Unknown/unsupported storage engine: InnoDB Apr 24 08:33:16 hw-1-8 mariadbd[13864]: 2021-04-24 8:33:16 0 [ERROR] Aborting Apr 24 08:33:17 hw-1-8 systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE Apr 24 08:33:17 hw-1-8 systemd[1]: Failed to start MariaDB 10.5.9 database server. -- Subject: Unit mariadb.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mariadb.service has failed. -- -- The result is failed. Apr 24 08:33:17 hw-1-8 systemd[1]: Unit mariadb.service entered failed state. =====================此處省略若干======================== Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Note] /usr/sbin/mariadbd (mysqld 10.5.9-MariaDB) starting as process 13946 ... Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Warning] Could not increase number of max_open_files to more than 16384 (reques Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Note] InnoDB: Uses event mutexes Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Note] InnoDB: Compressed tables use zlib 1.2.7 Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Note] InnoDB: Number of pools: 1 Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Note] InnoDB: Using Linux native AIO Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 13 Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Note] InnoDB: Completed initialization of buffer pool Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread p Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [ERROR] InnoDB: Invalid flags 0x4800 in ./ibdata1 Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [ERROR] InnoDB: Plugin initialization aborted with error Data structure corrupti Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Note] InnoDB: Starting shutdown... Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [ERROR] Plugin 'InnoDB' init function returned error. Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [Note] Plugin 'FEEDBACK' is disabled. Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [ERROR] Unknown/unsupported storage engine: InnoDB Apr 24 08:36:14 hw-1-8 mariadbd[13946]: 2021-04-24 8:36:14 0 [ERROR] Aborting Apr 24 08:36:14 hw-1-8 systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE Apr 24 08:36:14 hw-1-8 systemd[1]: Failed to start MariaDB 10.5.9 database server. -- Subject: Unit mariadb.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mariadb.service has failed. -- -- The result is failed. Apr 24 08:36:14 hw-1-8 systemd[1]: Unit mariadb.service entered failed state. Apr 24 08:36:14 hw-1-8 systemd[1]: mariadb.service failed. Apr 24 08:36:14 hw-1-8 polkitd[769]: Unregistered Authentication Agent for unix-process:13926:320856 (system bus name :1.68, object path /org/ Apr 24 08:36:17 hw-1-8 sshd[13954]: Did not receive identification string from
從上面報錯內容中發現“ InnoDB: Invalid flags 0x4800 in ./ibdata1”這樣的報錯,百度查找了原因,說是:高版本數據庫時創建的一些數據庫數據都還在,使用的是高版本的InnoDB引擎,而低版本的數據庫服務還是指向了這些數據,但是一些版本的數據格式不同,這個時候,我們只要把高版本的數據刪掉就可以了,刪掉后重新啟動mysql就可以了。
當然,解決問題,如果是全新安裝,可以采用這種形式,如果是降級安裝,則需要將數據備份出來,然后在刪除目錄,重新啟動。
以上是yum 安裝的過程。 當然,不滿足于rpm安裝的,可以自行編譯安裝。
還有小伙伴可能對主從,備份等感興趣,敬請參考其他文檔。
CentOS MySQL yum
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。