1. 去官網(wǎng)下載安裝包
下載鏈接:點擊打開鏈接
https://dev.mysql.com/downloads/mysql/
如果你的系統(tǒng)是32位選擇第一個,64位選擇第二個
也可以用wget 下載
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-i686.tar.gz
解壓文件
tar -zxvf mysql-8.0.11-linux-glibc2.12-i686.tar.gz
2 移動壓縮包到usr/local目錄下,并重命名文件
mv /root/mysql-8.0.11-linux-glibc2.12-i686 /usr/local/mysql
3.在MySQL根目錄下新建一個文件夾data,用于存放數(shù)據(jù)
4.創(chuàng)建 mysql 用戶組和 mysql 用戶
groupadd mysql
useradd -g mysql mysql
5.改變 mysql 目錄權(quán)限
chown -R mysql.mysql /usr/local/mysql/
或者
chown -R mysql .
chgrp -R mysql .
注意最后有一點
6.初始化數(shù)據(jù)庫
創(chuàng)建mysql_install_db安裝文件
mkdir mysql_install_db
chmod 777 ./mysql_install_db
初始化
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data //初始化數(shù)據(jù)庫
或者
/usr/local/mysql/bin/mysqld --initialize --user=mysql
/usr/local/mysql/bin/mysqld --initialize --user=mysql
/usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 5826
[Server] A temporary password is generated for root@localhost: twi=Tlsi0O!
/usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server has completed
記錄好自己的臨時密碼:
twi=Tlsi0O!
這里遇到了問題沒有l(wèi)ibnuma.so.1
zsh: command not found: mysqld
./bin/mysqld --initialize
./bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
2018-04-29 17:06:30 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2018-04-29 17:06:30 [ERROR] Can't locate the language directory.
需要安裝 libnuma
yum install libnuma
yum -y install numactl
yum install libaio1 libaio-dev
安裝文件
7.mysql配置
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
修改my.cnf文件
vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /usr/local/mysql/mysql.sock
character-set-server=utf8
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket = /usr/local/mysql/mysql.sock
default-character-set=utf8
esc保存
:wq 退出
8建立MySQL服務(wù)
cp -a ./support-files/mysql.server /etc/init.d/mysqld
cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
添加到系統(tǒng)服務(wù)
cp -a ./support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
檢查服務(wù)是否生效
chkconfig --list mysqld
9. 配置全局環(huán)境變量
編輯 / etc/profile 文件
# vi /etc/profile
在 profile 文件底部添加如下兩行配置,保存后退出
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH
設(shè)置環(huán)境變量立即生效
source /etc/profile
10.啟動MySQL服務(wù)
service mysql start
查看初始密碼
cat /root/.mysql_secret
11.登錄MySQL
mysql -uroot -p密碼
修改密碼:
SET PASSWORD FOR 'root'@localhost=PASSWORD('123456'); #對應(yīng)的換成你自己的密碼即可了。
12設(shè)置可以遠(yuǎn)程登錄
mysql>use mysql
mysql>update user set host='%' where user='root' limit 1;
刷新權(quán)限
mysql>flush privileges;
然后檢查3306端口是否開放
netstat -nupl|grep 3306
開放3306端口
firewall -cmd --permanent --add-prot=3306/tcp
重啟防火墻
firewall -cmd --reload
總結(jié)
以上所述是小編給大家介紹的Linux下安裝MySQL8.0.11的教程,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
您可能感興趣的文章:- mysql 8.0.11 安裝步驟詳解
- mysql 8.0.11 macos10.13安裝配置方法圖文教程
- 安裝mysql8.0.11及修改root密碼、連接navicat for mysql的思路詳解
- MySql 8.0.11 安裝過程及 Navicat 鏈接時遇到的問題小結(jié)
- MySQL Community Server 8.0.11安裝配置方法圖文教程
- mysql8.0.11 winx64安裝配置方法圖文教程(win10)
- MySQL8.0.11安裝總結(jié)教程圖解
- mysql-8.0.11-winx64.zip安裝教程詳解