Centos7 如何部署MySQL8.0.30數(shù)據(jù)庫
一、下載MySQL
官網(wǎng):https://dev.mysql.com/downloads/mysql/
二、安裝
2.1、將mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz文件上傳到服務器中
如圖:
解壓命令:
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ù)庫時會報如下錯誤:
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 # 授權 chown -R mysql.mysql /usr/local/mysql-8.0.30
2.5、初始化數(shù)據(jù)庫
# 不忽略表名大小寫 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
初始化后會有一個默認密碼,找到root@localhost:,后面就是初始密碼,將初始密碼復制出來
注意:在初始化數(shù)據(jù)庫時需區(qū)分忽略大小寫問題,如果初始化時沒有設置忽略大小寫,后面在配置文件配置后,重啟MySQL會報錯,如下:
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
授權文件my.cnf
cd /etc/ chown mysql:mysql my.cnf chown mysql my.cnf chmod 755 my.cnf
2.7、設置開機自啟動
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、啟動MySQL
# 啟動 service start mysqld # 停止 service stop mysqld # 查看狀態(tài) service status mysqld
2.9、修改密碼、密碼插件
進入MySQL,輸入初始密碼進入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;
到此這篇關于Centos7 如何部署MySQL8.0.30數(shù)據(jù)庫的文章就介紹到這了,更多相關Centos7 部署MySQL8.0.30內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
- Centos7下安裝MySQL8.0.23的步驟(小白入門級別)
- mysql8.0.23 linux(centos7)安裝完整超詳細教程
- 阿里云centos7安裝mysql8.0.22的詳細教程
- CentOS7版本安裝Mysql8.0.20版本數(shù)據(jù)庫的詳細教程
- 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
相關文章
抽取oracle數(shù)據(jù)到mysql數(shù)據(jù)庫的實現(xiàn)過程
今天小編就為大家分享一篇關于抽取oracle數(shù)據(jù)到mysql數(shù)據(jù)庫的實現(xiàn)過程,小編覺得內容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-02-02解決SQLyog連接MySQL出現(xiàn)錯誤Plugin caching_sha2_password co
當使用SQLyog連接MySQL時,如果遇到插件caching_sha2_password無法加載的錯誤,可以通過更改密碼并將其標識為mysql_native_password來解決,具體步驟包括:打開命令提示符窗口,登錄MySQL,修改密碼并更換插件,然后使用新密碼連接SQLyog2025-01-01mysql 5.7.13 winx64安裝配置方法圖文教程(win10)
這篇文章主要為大家分享了mysql 5.7.13 winx64安裝配置方法圖文教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-01-01