Linux 安裝部署mysql8.0.13

//下載 mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz

[root@root ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz

//解壓mysql

[root@root ~]# tar -xJvf mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz 
……
mysql-8.0.13-linux-glibc2.12-x86_64/bin/myisamchk
mysql-8.0.13-linux-glibc2.12-x86_64/bin/myisamlog
mysql-8.0.13-linux-glibc2.12-x86_64/bin/myisampack

…… //解壓完成
//重命名mysql-8.0.13-linux-glibc2.12-x86_64文件夾為mysql

[root@root ~]# mv mysql-8.0.13-linux-glibc2.12-x86_64 mysql

//將mysql移到/usr/local/ 目錄下

[root@root ~]# mv /root/mysql /usr/local/
mv:是否覆蓋"/usr/local/mysql"帆精? y

//添加mysql用戶組及MySQL用戶

[root@root ~]# groupadd mysql
[root@root ~]# useradd -r -g mysql mysql

//設置/usr/local/mysql/文件夾的用戶權(quán)限

[root@root ~]# cd /usr/local/mysql/
[root@root mysql]# chown -R mysql:mysql ./

//新建MySQL數(shù)據(jù)存儲文件夾

[root@root mysql]# mkdir data

//初始化mysql數(shù)據(jù)庫丈探,生成默認密碼

[root@root mysql]#  bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
2018-12-22T05:24:39.603264Z 0 [Warning] [MY-011070] [Server] 'Disablining --skip-symbolic-links (or equivalent) is the default. Consider notas it' is deprecated and will be removed in a future release.
2018-12-22T05:24:39.603444Z 0 [System] [MY-013169] [Server] /usr/localmysqld 8.0.13) initializing of server in progress as process 27519
2018-12-22T05:24:41.891360Z 5 [Note] [MY-010454] [Server] A temporary ed for root@localhost: ePrOX&p>L52#  //這是初始默認密碼
2018-12-22T05:24:43.475923Z 0 [System] [MY-013170] [Server] /usr/localmysqld 8.0.13) initializing of server has completed
[Server] A temporary password is generated for root@localhost: lqs-.d,fN1pB
[root@iZwz9ijcs0cia5xad0sewhZ mysql]#  bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
2019-07-01T08:42:30.346859Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.16) initializing of server in progress as process 15888
2019-07-01T08:42:33.616199Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: lqs-.d,fN1pB
2019-07-01T08:42:35.006735Z 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.16) initializing of server has completed

//設置數(shù)據(jù)庫存儲文件夾的用戶權(quán)限

[root@root mysql]# chown -R root:root ./
[root@root mysql]# chown -R mysql:mysql data

//修改etc/my.cnf配置文件

[root@root ~]# vim /etc/my.cnf 

//修改為以下內(nèi)容:

[mysqld]
server-id                      = 1
port                           = 3306
bind-address                   = 0.0.0.0 
max_connections                = 5000
mysqlx_port                    = 33060
mysqlx_socket                  = /tmp/mysqlx.sock
basedir                        = /usr/local/mysql
datadir                        = /usr/local/mysql/data
socket                         = /tmp/mysql.sock
pid-file                       = /tmp/mysqld.pid
slow_query_log                 = ON
slow_query_log_file            = /usr/local/mysql/logs/slow.log
log-error                      = /usr/local/mysql/logs/error.log
long_query_time                = 0.2
log-bin                        = bin.log
relay-log                      = relay.log
binlog_format                  = ROW
relay_log_recovery             = 1
character-set-client-handshake = FALSE
character-set-server           = utf8mb4
collation-server               = utf8mb4_unicode_ci
init_connect                   ='SET NAMES utf8mb4'
innodb_buffer_pool_size        = 1G
join_buffer_size               = 128M
sort_buffer_size               = 2M
read_rnd_buffer_size           = 2M
log_timestamps                 = SYSTEM
lower_case_table_names         = 1
default-authentication-plugin  = mysql_native_password

保存退出。

[root@root mysql]# chmod 777 /etc/my.cnf 

//設置開機自啟動

[root@root mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@root mysql]# chmod +x /etc/init.d/mysql 

//注冊查看服務

[root@root mysql]# chkconfig --add mysql
[root@root mysql]# chkconfig --list mysql
mysql              0:關(guān)閉    1:關(guān)閉    2:啟用    3:啟用    4:啟用    5:啟用    6:關(guān)閉

// /etc/ld.so.conf 這個文件記錄了編譯時使用的動態(tài)鏈接庫的路徑,告訴鏈接器去哪個路徑下尋找鏈接時需要用到的庫岸售,如果找不到草冈,就會提示鏈接錯誤瞎领。
如果我們安裝了第三方的庫黎做,而沒有將它放在鏈接器可以找到的目錄,則運行使用這些第三方庫的程序時阳堕,會提示找不到庫跋理。

[root@root mysql]# vim /etc/ld.so.cnf

添加如下內(nèi)容:

include ld.so.conf.d/*.conf
/usr/local/mysql/lib

//配置環(huán)境變量

[root@root mysql]# vim /etc/profile

添加如下內(nèi)容:

export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib

//讓配置文件立馬生效

[root@root mysql]# source /etc/profile

//啟動MySQL服務

[root@root mysql]# service mysql start

//使用生成的密碼登陸MySQL數(shù)據(jù)庫

[root@root mysql]# mysql -u root -p
mysql: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.13
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

//修改密碼

mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.13 sec)
mysql> exit
Bye

//退出重登錄mysql

[root@root mysql]# mysql -u root -p
mysql: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

到此安裝完成!

這里設置的 /etc/my.cnf 權(quán)限是777 恬总,就是任何人都可讀可寫前普,my.cnf 會被忽略掉,mysql的安全機制壹堰,也可以不要my.cnf配置文件拭卿。

下面設置一下MySQL的遠程訪問
簡單寫一下命令,自己寫的時候忘了記錄贱纠,網(wǎng)上也是一大堆峻厚。
登陸mysql

mysql -u root -p 
use mysql;
select host,user from user;
 
CREATE USER 'root'@'%' IDENTIFIED BY '123456';
GRANT ALL ON *.* TO 'root'@'%';
flush privileges;
ALTER USER 'root'@'%' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER; 
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; 
FLUSH PRIVILEGES; 

下面一定要記得關(guān)閉防火墻

service iptables stop

設置防火墻開機不啟動

chkconfig iptables off 

然后關(guān)機重啟,連接試一試吧谆焊!

注意事項:
如果出現(xiàn)以下報錯信息:

# [mysql初始化時報錯bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory的處理](https://www.cnblogs.com/chuanzhang053/p/9474797.html)
[mysql初始化時報錯bin/mysqld: error while loading shared libraries: libnuma.so.1: 安裝mysql

那么執(zhí)行下:

[root@testvm01 mysql]# yum -y install numactl
...
[root@testvm01 mysql]# bin/mysqld --initialize --user=mysql
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末目木,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌刽射,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,284評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件剃执,死亡現(xiàn)場離奇詭異誓禁,居然都是意外死亡,警方通過查閱死者的電腦和手機肾档,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,115評論 3 395
  • 文/潘曉璐 我一進店門摹恰,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人怒见,你說我怎么就攤上這事俗慈。” “怎么了遣耍?”我有些...
    開封第一講書人閱讀 164,614評論 0 354
  • 文/不壞的土叔 我叫張陵闺阱,是天一觀的道長。 經(jīng)常有香客問我舵变,道長酣溃,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,671評論 1 293
  • 正文 為了忘掉前任纪隙,我火速辦了婚禮赊豌,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘绵咱。我一直安慰自己碘饼,他們只是感情好,可當我...
    茶點故事閱讀 67,699評論 6 392
  • 文/花漫 我一把揭開白布悲伶。 她就那樣靜靜地躺著艾恼,像睡著了一般。 火紅的嫁衣襯著肌膚如雪拢切。 梳的紋絲不亂的頭發(fā)上蒂萎,一...
    開封第一講書人閱讀 51,562評論 1 305
  • 那天,我揣著相機與錄音淮椰,去河邊找鬼五慈。 笑死,一個胖子當著我的面吹牛主穗,可吹牛的內(nèi)容都是我干的泻拦。 我是一名探鬼主播,決...
    沈念sama閱讀 40,309評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼忽媒,長吁一口氣:“原來是場噩夢啊……” “哼争拐!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起晦雨,我...
    開封第一講書人閱讀 39,223評論 0 276
  • 序言:老撾萬榮一對情侶失蹤架曹,失蹤者是張志新(化名)和其女友劉穎隘冲,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體绑雄,經(jīng)...
    沈念sama閱讀 45,668評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡展辞,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,859評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了万牺。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片罗珍。...
    茶點故事閱讀 39,981評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖脚粟,靈堂內(nèi)的尸體忽然破棺而出覆旱,到底是詐尸還是另有隱情,我是刑警寧澤核无,帶...
    沈念sama閱讀 35,705評論 5 347
  • 正文 年R本政府宣布扣唱,位于F島的核電站,受9級特大地震影響厕宗,放射性物質(zhì)發(fā)生泄漏画舌。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,310評論 3 330
  • 文/蒙蒙 一已慢、第九天 我趴在偏房一處隱蔽的房頂上張望曲聂。 院中可真熱鬧,春花似錦佑惠、人聲如沸朋腋。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,904評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽旭咽。三九已至,卻和暖如春赌厅,著一層夾襖步出監(jiān)牢的瞬間穷绵,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,023評論 1 270
  • 我被黑心中介騙來泰國打工特愿, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留仲墨,地道東北人。 一個月前我還...
    沈念sama閱讀 48,146評論 3 370
  • 正文 我出身青樓揍障,卻偏偏與公主長得像目养,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子毒嫡,可洞房花燭夜當晚...
    茶點故事閱讀 44,933評論 2 355

推薦閱讀更多精彩內(nèi)容

  • mysqladmin -u root -p oldpass password newpass mysqladmin...
    不排版閱讀 2,165評論 0 3
  • 官方下載地址 : https://dev.mysql.com/downloads/mysql/ 操作系統(tǒng)我們選擇l...
    yandaren閱讀 249評論 0 0
  • Mysql數(shù)據(jù)庫的安裝對于開發(fā)者來說癌蚁,是我們必然會面對的問題,它的安裝過程其實并不復雜,并且網(wǎng)上的安裝教程也非常多...
    alone_f0fd閱讀 318評論 1 1
  • 前言 最近努释,準備進行MM+keepalive實現(xiàn)mysql高可用碘梢,于是直接某度搜linux安裝mysql,各種花里...
    996_幕者_669閱讀 323評論 0 1
  • 安裝并配置MySQL數(shù)據(jù)庫 3.2.1安裝MySQL數(shù)據(jù)庫 1.MySQL數(shù)據(jù)庫的安裝環(huán)境準備 如果讀者沒有物理服...
    SkTj閱讀 4,043評論 0 6