安裝:MySQL mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

1、下載mysql-5.7.19源碼包(不需要編譯):

$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

2、我們需要新建一個(gè)mysql組

$ sudo groupadd mysql

3、新建一個(gè)mysql用戶加入該組

$ sudo useradd -r -g mysql mysql

4、解壓縮

$ tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

5、將解壓之后的文件改名為mysql 放到 /opt下邊

$ mv mysql-5.7.19-linux-glibc2.12-x86_64 /opt/mysql

6、進(jìn)入到/opt/mysql目錄下更改權(quán)限

$ chown -R mysql . //將當(dāng)前目錄的擁有者權(quán)限更改為mysql
$ chgrp -R mysql . //將當(dāng)前的目錄的組權(quán)限更改為mysql組

7、安裝輔助的庫文件,當(dāng)然不是必須的看你系統(tǒng)中是不是有

$ sudo apt-get intall libaio1

8、在/etc目錄下創(chuàng)建文件my.cnf,并且填寫設(shè)置內(nèi)容

$ cd /etc
$ touch my.cnf
$ vi my.cnf
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
explicit_defaults_for_timestamp=true
basedir = /opt/mysql
datadir = /data/mysql
port = 3306
socket = /opt/mysql/mysqld/mysql.sock
pid-file = /opt/mysql/mysqld/mysql.pid
character-set-server=utf8
back_log = 300
max_connections = 3000
max_connect_errors = 50
table_open_cache = 4096
max_allowed_packet = 32M
max_heap_table_size = 128M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 16
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len = 8
thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
long_query_time = 6
server_id=1
innodb_buffer_pool_size = 1G
innodb_thread_concurrency = 16
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = on
[mysqldump]
quick
max_allowed_packet = 32M
[mysql]
no-auto-rehash
default-character-set=utf8
safe-updates
[myisamchk]
key_buffer = 16M
sort_buffer_size = 16M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
[client]
port = 3306
socket = /opt/mysql/mysqld/mysql.sock
default-character-set = utf8

9、創(chuàng)建文件夾/data/mysql,/opt/mysql/mysqld

$ mkdir -p /data/mysql
$ chown -R mysql:mysql /data/mysql
$ chmod -R 755 /data/mysql
$ mkdir -p /opt/mysql/mysqld
$ chown -R mysql:mysql /opt/mysql/mysqld
$ chmod -R 755 /opt/mysql/mysqld

10、到解壓的mysql目錄中找到bin ,在bin中有 mysqld 可執(zhí)行文件。執(zhí)行

$ ./mysqld --user=mysql --basedir=/opt/mysql --datadir=/data/mysql --initialize

2017-07-31T16:59:21.450195Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-31T16:59:21.990321Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-07-31T16:59:22.084681Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-07-31T16:59:22.150650Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 99984cd2-7611-11e7-9025-58946bfd7c3c.
2017-07-31T16:59:22.153325Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-07-31T16:59:22.154050Z 1 [Note] A temporary password is generated for root@localhost: dsuIequSe5>E

由上面信息可得:dsuIequSe5>E (為root用戶的臨時(shí)登錄密碼)

11、創(chuàng)建鏈接

$ ln -fs /opt/mysql/bin/mysql /usr/local/bin/mysql
$ cp /opt/mysql/support-files/mysql.server /etc/init.d/mysqld

12、配置系統(tǒng)環(huán)境變量
MYSQL_HOME=/opt/mysql/bin
PATH=$MYSQL_HOME/bin:$PATH
export MYSQL_HOME

12、啟動(dòng)MySQL服務(wù)

$ /etc/init.d/mysqld start
或者 進(jìn)入MySQL安裝目錄/opt/mysql/bin文件夾中,執(zhí)行下面的命令
$ ./mysqld_safe --user=mysql &
我的啟動(dòng)服務(wù)方式:systemctl start mysql
PS:如果啟動(dòng)、停止服務(wù)失敗的話,重啟系統(tǒng),在啟動(dòng)mysql服務(wù)

13、登錄MySQL數(shù)據(jù)庫

$ mysql --user=root -p
密碼:步驟10中生成的零時(shí)密碼
mysql> set password=password('Aber<S>');

Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> grant all privileges on × to root@'%' identified by 'password';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容