1.下載官方打包好的二進制安裝包:
#wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
可以看到這個版本采用了tar.xz的打包壓縮方式仑氛,文件只有350M左右,下載還是滿方便的。
# du -sh mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
339M mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
2.解壓文件:
#tar -xJvf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
# mv /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/ /usr/local/mysql
3.配置參數(shù)文件:
# cat /etc/my.cnf
[mysqld]
server-id = 1
port = 3306
mysqlx_port = 33060
mysqlx_socket = /tmp/mysqlx.sock
datadir = /data/mysql
socket = /tmp/mysql.sock
pid-file = /tmp/mysqld.pid
log-error = error.log
slow-query-log = 1
slow-query-log-file = slow.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
4.創(chuàng)建目錄授權(quán)等:
# groupadd mysql
# useradd mysql
# mkdir -p /data/mysql
# chown -R mysql:mysql /data/mysql/
# chmod -R 775 /data/mysql/
5.初始化數(shù)據(jù)庫:
#/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize-insecure
官方推薦使用--initialize庐舟,會在錯誤日志中生成難以輸入的臨時密碼,我這里使用的免密碼的方式锰悼。
# cat /data/mysql/error.log | grep -i password
2018-07-29T02:06:41.253856+08:00 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wquR3-Kxlg1d
6.設(shè)置啟動文件和環(huán)境變量:
#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
--啟動數(shù)據(jù)庫:
# /etc/init.d/mysql start
Starting MySQL.Logging to '/data/mysql/error.log'.
SUCCESS!
# vim /etc/profile.d/mysql.sh
# cat /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin
# source /etc/profile.d/mysql.sh
# mysqld --version
mysqld Ver 8.0.12 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
[root@node4 mysql]# /usr/local/mysql/bin/mysql -p -S /tmp/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.12 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> select version();
+-----------+
| version() |
+-----------+
| 8.0.12 |
+-----------+
1 row in set (0.00 sec)
7.設(shè)置可以遠程登錄的賬號:
mysql> show variables like '%valid%pass%';
Empty set (0.00 sec)
mysql> create user root@'%' identified by 'oracle';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> show variables like '%valid%pass%';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user root@'localhost' identified by 'oracle';
Query OK, 0 rows affected (0.07 sec)
mysql> show variables like '%valid%pass%';
Empty set (0.01 sec)
--創(chuàng)建可以遠程登錄的用戶:
mysql> create user root@'%' identified by 'oracle';
Query OK, 0 rows affected (0.06 sec)
mysql> grant all privileges on *.* to root@'%' with grant option;
Query OK, 0 rows affected (0.07 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
總結(jié):
官方雖然提供RPM安裝方式但是不少默認參數(shù)還是不太方便平常的使用窘俺,對生產(chǎn)而言則需要修改更多的地方,但是很適合初級用戶快速安裝使用矛绘;
而對二進制安裝包 只需要下載按照自定義的設(shè)置安裝即可 方便快捷 可自主配置,適合生產(chǎn)布署刃永。
Linux MySQL8.0.12安裝
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門铃在,熙熙樓的掌柜王于貴愁眉苦臉地迎上來阵具,“玉大人,你說我怎么就攤上這事定铜⊙粢海” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵揣炕,是天一觀的道長帘皿。 經(jīng)常有香客問我,道長畸陡,這世上最難降的妖魔是什么鹰溜? 我笑而不...
- 正文 為了忘掉前任,我火速辦了婚禮丁恭,結(jié)果婚禮上奉狈,老公的妹妹穿的比我還像新娘。我一直安慰自己涩惑,他們只是感情好仁期,可當我...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著竭恬,像睡著了一般跛蛋。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上痊硕,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼刚盈!你這毒婦竟也來了羡洛?” 一聲冷哼從身側(cè)響起,我...
- 正文 年R本政府宣布舀奶,位于F島的核電站,受9級特大地震影響斋射,放射性物質(zhì)發(fā)生泄漏育勺。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一罗岖、第九天 我趴在偏房一處隱蔽的房頂上張望涧至。 院中可真熱鬧,春花似錦桑包、人聲如沸南蓬。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽赘方。三九已至,卻和暖如春弱左,著一層夾襖步出監(jiān)牢的瞬間窄陡,已是汗流浹背。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- 1套硼、到網(wǎng)站下載dmg:https://dev.mysql.com/downloads/mysql/ 2、按照流程進...
- 一直在使用jQuery晶疼,也一直想更深層次的學習jQuery,下面就從jQuery的結(jié)構(gòu)說起又憨。并通過一個小例子翠霍,實現(xiàn)...