Centos7 如何部署MySQL8.0.30數(shù)據(jù)庫(kù)
一、下載MySQL
官網(wǎng):https://dev.mysql.com/downloads/mysql/
二、安裝
2.1、將mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz文件上傳到服務(wù)器中
如圖:
解壓命令:
xz -d mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz # 將tar文件解壓到/usr/local/目錄下 tar -xvf mysql-8.0.30-linux-glibc2.12-x86_64.tar -C /usr/local cd /usr/local/ # 修改MySQL文件名 mv mysql-8.0.30-linux-glibc2.12-x86_64 mysql-8.0.30 # 創(chuàng)建數(shù)據(jù)存放目錄 mkdir /usr/local/mysql-8.0.30/data
2.2、檢查libaio是否有安裝
yum search libaio
圖中是有安裝過了
安裝命令:
yum install libaio
如果沒有安裝libaio,在初始化數(shù)據(jù)庫(kù)時(shí)會(huì)報(bào)如下錯(cuò)誤:
mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
2.3、配置環(huán)境變量
vim /etc/profile
export MYSQL_HOME=/usr/local/mysql-8.0.30/bin export PATH=$PATH:$MYSQL_HOME
配置好后保存退出,并重新加載配置
source /etc/profile
2.4、創(chuàng)建用戶、用戶組
# 創(chuàng)建用戶 groupadd mysql # 創(chuàng)建用戶組 useradd -g mysql mysql # 授權(quán) chown -R mysql.mysql /usr/local/mysql-8.0.30
2.5、初始化數(shù)據(jù)庫(kù)
# 不忽略表名大小寫 mysqld --user=mysql --basedir=/usr/local/mysql-8.0.30 --datadir=/usr/local/mysql-8.0.30/data/ --initialize # 忽略表名大小寫 mysqld --user=mysql --lower-case-table-names=1 --basedir=/usr/local/mysql-8.0.30 --datadir=/usr/local/mysql-8.0.30/data/ --initialize
初始化后會(huì)有一個(gè)默認(rèn)密碼,找到root@localhost:,后面就是初始密碼,將初始密碼復(fù)制出來
注意:在初始化數(shù)據(jù)庫(kù)時(shí)需區(qū)分忽略大小寫問題,如果初始化時(shí)沒有設(shè)置忽略大小寫,后面在配置文件配置后,重啟MySQL會(huì)報(bào)錯(cuò),如下:
2.6、修改/etc/my.cnf配置文件
[client] port=3306 socket=/tmp/mysql.sock default-character-set=utf8mb4 [mysqld] basedir=/usr/local/mysql-8.0.30 datadir=/usr/local/mysql-8.0.30/data socket=/tmp/mysql.sock user=mysql port=3306 character_set_server=utf8mb4 # explicit_defaults_for_timestamp=true lower_case_table_names = 1 sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION [mysqld_safe] log-error=/usr/local/mysql-8.0.30/data/error.log pid-file=/usr/local/mysql-8.0.30/data/mysqld.pid tmpdir=/tmp
授權(quán)文件my.cnf
cd /etc/ chown mysql:mysql my.cnf chown mysql my.cnf chmod 755 my.cnf
2.7、設(shè)置開機(jī)自啟動(dòng)
cp /usr/local/mysql-8.0.30/support-files/mysql.server /etc/init.d/mysqld chmod 755 /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on
2.8、啟動(dòng)MySQL
# 啟動(dòng) service start mysqld # 停止 service stop mysqld # 查看狀態(tài) service status mysqld
2.9、修改密碼、密碼插件
進(jìn)入MySQL,輸入初始密碼進(jìn)入mysql
mysql -u root -p
修改初始密碼:
alter user 'root'@'localhost' identified by '123456';
修改密碼插件
update user set authentication_string='' where user='root'; flush privileges; update user set plugin='mysql_native_password' where user='root'; flush privileges; # 允許除localhost外訪問 update user set host='%' where user='root' and host='localhost'; flush privileges; ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密碼'; flush privileges;
到此這篇關(guān)于Centos7 如何部署MySQL8.0.30數(shù)據(jù)庫(kù)的文章就介紹到這了,更多相關(guān)Centos7 部署MySQL8.0.30內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Centos7下安裝MySQL8.0.23的步驟(小白入門級(jí)別)
- mysql8.0.23 linux(centos7)安裝完整超詳細(xì)教程
- 阿里云centos7安裝mysql8.0.22的詳細(xì)教程
- CentOS7版本安裝Mysql8.0.20版本數(shù)據(jù)庫(kù)的詳細(xì)教程
- CentOS7.8安裝mysql 8.0.20的教程詳解
- linux(Centos7)下安裝mysql8.0.18的教程圖解
- CentOS7.6安裝MYSQL8.0的步驟詳解
- CentOS7下mysql 8.0.16 安裝配置方法圖文教程
- Centos7下mysql 8.0.15 安裝配置圖文教程
- centos7利用yum安裝mysql 8.0.12
相關(guān)文章
抽取oracle數(shù)據(jù)到mysql數(shù)據(jù)庫(kù)的實(shí)現(xiàn)過程
今天小編就為大家分享一篇關(guān)于抽取oracle數(shù)據(jù)到mysql數(shù)據(jù)庫(kù)的實(shí)現(xiàn)過程,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧2019-02-02Mac?Homebrew安裝的MySQL無法遠(yuǎn)程登錄的解決
這篇文章主要介紹了Mac?Homebrew安裝的MySQL無法遠(yuǎn)程登錄的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-11-11解決SQLyog連接MySQL出現(xiàn)錯(cuò)誤Plugin caching_sha2_password co
當(dāng)使用SQLyog連接MySQL時(shí),如果遇到插件caching_sha2_password無法加載的錯(cuò)誤,可以通過更改密碼并將其標(biāo)識(shí)為mysql_native_password來解決,具體步驟包括:打開命令提示符窗口,登錄MySQL,修改密碼并更換插件,然后使用新密碼連接SQLyog2025-01-01mysql 5.7.13 winx64安裝配置方法圖文教程(win10)
這篇文章主要為大家分享了mysql 5.7.13 winx64安裝配置方法圖文教程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01