MySQL 5.7.11 源碼安裝

離線部署mysql
[[email protected] cdh5.16.1]# tar -zxvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
[[email protected] local]# chown -R root:root mysql-5.7.11-linux-glibc2.5-x86_64/
[[email protected] local]# chown -R root:root mysql-5.7.11-linux-glibc2.5-x86_64/*

[[email protected] local]# mv mysql-5.7.11-linux-glibc2.5-x86_64/ mysql
[[email protected] local]# mkdir mysql/arch mysql/data mysql/tmp
[[email protected] local]# vi /etc/my.cnf
[client]


port = 3306
socket = /usr/local/mysql/data/mysql.sock
default-character-set=utf8mb4


[mysqld]
port = 3306
socket = /usr/local/mysql/data/mysql.sock


skip-slave-start


skip-external-locking
key_buffer_size = 256M
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 4M
query_cache_size= 32M
max_allowed_packet = 16M
myisam_sort_buffer_size=128M
tmp_table_size=32M


table_open_cache = 512
thread_cache_size = 8
wait_timeout = 86400
interactive_timeout = 86400
max_connections = 600


# Try number of CPU's*2 for thread_concurrency
#thread_concurrency = 32


#isolation level and default engine
default-storage-engine = INNODB
transaction-isolation = READ-COMMITTED


server-id = 1739
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/data/hostname.pid


#open performance schema
log-warnings
sysdate-is-now


binlog_format = ROW
log_bin_trust_function_creators=1
log-error = /usr/local/mysql/data/hostname.err
log-bin = /usr/local/mysql/arch/mysql-bin
expire_logs_days = 7


innodb_write_io_threads=16


relay-log = /usr/local/mysql/relay_log/relay-log
relay-log-index = /usr/local/mysql/relay_log/relay-log.index
relay_log_info_file= /usr/local/mysql/relay_log/relay-log.info


log_slave_updates=1
gtid_mode=OFF
enforce_gtid_consistency=OFF


# slave
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=4
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON


#other logs
#general_log =1
#general_log_file = /usr/local/mysql/data/general_log.err
#slow_query_log=1
#slow_query_log_file=/usr/local/mysql/data/slow_log.err


#for replication slave
sync_binlog = 500




#for innodb options
innodb_data_home_dir = /usr/local/mysql/data/
innodb_data_file_path = ibdata1:1G;ibdata2:1G:autoextend


innodb_log_group_home_dir = /usr/local/mysql/arch
innodb_log_files_in_group = 4
innodb_log_file_size = 1G
innodb_log_buffer_size = 200M


#根據生產需要,調整pool size
innodb_buffer_pool_size = 2G
#innodb_additional_mem_pool_size = 50M #deprecated in 5.6
tmpdir = /usr/local/mysql/tmp


innodb_lock_wait_timeout = 1000
#innodb_thread_concurrency = 0
innodb_flush_log_at_trx_commit = 2


innodb_locks_unsafe_for_binlog=1


#innodb io features: add for mysql5.5.8
performance_schema
innodb_read_io_threads=4
innodb-write-io-threads=4
innodb-io-capacity=200
#purge threads change default(0) to 1 for purge
innodb_purge_threads=1
innodb_use_native_aio=on


#case-sensitive file names and separate tablespace
innodb_file_per_table = 1
lower_case_table_names=1


[mysqldump]
quick
max_allowed_packet = 128M


[mysql]
no-auto-rehash
default-character-set=utf8mb4


[mysqlhotcopy]
interactive-timeout


[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

注意:把配置文件的內容全清除

創建用戶用戶組
[[email protected] local]# groupadd -g 101 dba
useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin

創建用戶有問題,需要執行下面一條命令操作
[[email protected] local]# cp /etc/skel/.* /usr/local/mysql/

配置環境變量
[[email protected] local]# vi mysql/.bash_profile
把原有的export刪除
export MYSQL_BASE=/usr/local/mysql
export PATH=${MYSQL_BASE}/bin:$PATH

unset USERNAME

#stty erase ^H
set umask to 022
umask 022
PS1=`uname -n`":"'$USER'":"'$PWD'":>"; export PS1

可以看一下效果
[[email protected] local]# su - mysqladmin
上一次登錄:六 5月 23 20:53:53 CST 2020pts/0 上
hadoop001:mysqladmin:/usr/local/mysql:>exit 
logout

賦予權限
[[email protected] local]# chown mysqladmin:dba /etc/my.cnf
[[email protected] local]# chmod 640 /etc/my.cnf
[[email protected] local]# chown -R mysqladmin:dba /usr/local/mysql/
[[email protected] local]# chmod -R 755 /usr/local/mysql/

設置開機自啓動
[[email protected] local]# cd /usr/local/mysql/
[[email protected] mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql
[[email protected] mysql]# chmod +x /etc/rc.d/init.d/mysql
[[email protected] mysql]# chkconfig --del mysql
[[email protected] mysql]# chkconfig --add mysql
[[email protected]001 mysql]# chkconfig --level 345 mysql on

[[email protected] mysql]# chkconfig --list

注意:該輸出結果只顯示 SysV 服務,並不包含原生 systemd 服務。SysV 配置數據可能被原生 systemd 配置覆蓋。 
      如果您想列出 systemd 服務,請執行 'systemctl list-unit-files'。
      欲查看對特定 target 啓用的服務請執行
      'systemctl list-dependencies [target]'。

aegis              0:關    1:關    2:開    3:開    4:開    5:開    6:關
mysql              0:關    1:關    2:開    3:開    4:開    5:開    6:關
netconsole         0:關    1:關    2:關    3:關    4:關    5:關    6:關
network            0:關    1:關    2:開    3:開    4:開    5:開    6:關

[[email protected] mysql]# yum -y install libaio
[[email protected] mysql]# su - mysqladmin

進行mysql初始化
hadoop001:mysqladmin:/usr/local/mysql:>bin/mysqld \
>  --defaults-file=/etc/my.cnf \
>  --user=mysqladmin \
>  --basedir=/usr/local/mysql/ \
>  --datadir=/usr/local/mysql/data/ \
>  --initialize

等待....

獲取初始密碼
hadoop001:mysqladmin:/usr/local/mysql:>cd data/
hadoop001:mysqladmin:/usr/local/mysql/data:>ll
total 2097196
-rw-r----- 1 mysqladmin dba         56 May 23 21:11 auto.cnf
-rw-r----- 1 mysqladmin dba       7727 May 23 21:12 hostname.err
-rw-r----- 1 mysqladmin dba        407 May 23 21:12 ib_buffer_pool
-rw-r----- 1 mysqladmin dba 1073741824 May 23 21:12 ibdata1
-rw-r----- 1 mysqladmin dba 1073741824 May 23 21:11 ibdata2
drwxr-x--- 2 mysqladmin dba       4096 May 23 21:11 mysql
drwxr-x--- 2 mysqladmin dba       4096 May 23 21:11 performance_schema
drwxr-x--- 2 mysqladmin dba      12288 May 23 21:12 sys

hadoop001:mysqladmin:/usr/local/mysql/data:>cat hostname.err | grep password
2020-05-23T13:11:59.402441Z 1 [Note] A temporary password is generated for [email protected]: _e;N9JPoIEjc

hadoop001:mysqladmin:/usr/local/mysql/data:>cd ..

啓動
hadoop001:mysqladmin:/usr/local/mysql:>/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &

查看mysql 端口
hadoop001:mysqladmin:/usr/local/mysql:>ps -ef | grep mysql
root     12115 11811  0 21:08 pts/0    00:00:00 su - mysqladmin
mysqlad+ 12116 12115  0 21:08 pts/0    00:00:00 -bash
mysqlad+ 12174 12116  0 21:15 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
mysqlad+ 12991 12174  0 21:15 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/hostname.err --pid-file=/usr/local/mysql/data/hostname.pid --socket=/usr/local/mysql/data/mysql.sock --port=3306
mysqlad+ 13023 12116  0 21:16 pts/0    00:00:00 ps -ef
mysqlad+ 13024 12116  0 21:16 pts/0    00:00:00 grep --color=auto mysql

hadoop001:mysqladmin:/usr/local/mysql:>exit 
logout

[[email protected] mysql]# ps -ef | grep mysql
mysqlad+ 12174     1  0 21:15 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
mysqlad+ 12991 12174  0 21:15 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/hostname.err --pid-file=/usr/local/mysql/data/hostname.pid --socket=/usr/local/mysql/data/mysql.sock --port=3306
root     13026 11811  0 21:18 pts/0    00:00:00 grep --color=auto mysql
[[email protected] mysql]# netstat -nlp|grep 12991
tcp6       0      0 :::3306                 :::*                    LISTEN      12991/mysqld        
unix  2      [ ACC ]     STREAM     LISTENING     64182    12991/mysqld         /usr/local/mysql/data/mysql.sock

[[email protected] mysql]# su - mysqladmin
hadoop001:mysqladmin:/usr/local/mysql:>service mysql status

嘗試登錄
hadoop001:mysqladmin:/usr/local/mysql:>mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.11-log

Copyright (c) 2000, 2016, 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> 

重置密碼
mysql> alter user [email protected] identified by 'Hadoop12345678';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'ROOT'@'%' IDENTIFIED BY 'Hadoop12345678';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql 包

鏈接:https://pan.baidu.com/s/1i27tEm1PVyp-iJ1ltaWXeQ  密碼:foue

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章