源碼安裝MySQL比較麻煩,需要安裝依賴包,然后進行編譯,時間較長,建議安裝二進制的MySQL,時間比較快;
榆次ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!用到的軟件包:
mysql-5.7.18.tar.gz
boost_1_59_0.tar.gz
1、安裝依賴包
yum -y install gcc* gcc-c++ ncurses* ncurses-devel* cmake* bison* libgcrypt* perl*
2、創(chuàng)建MySQL用戶:
[root@localhost ~]# mkdir -p /mysql/data
[root@localhost ~]# mkdir -p /mysql/mysql5718
[root@localhost ~]# chown -R mysql.mysql /mysql/
3、調(diào)整系統(tǒng)參數(shù)
[root@localhost ~]# vim /etc/security/limits.conf
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
[root@localhost ~]# vi /etc/security/limits.d/20-nproc.conf
* soft nproc 65535
[root@localhost ~]# vi /etc/profile
ulimit -u 65535
ulimit -n 65535
4、下載并解壓軟件
[root@localhost ~]# tar zxvf mysql-5.7.18.tar.gz -C /usr/src/
[root@localhost ~]# tar zxvf boost_1_59_0.tar.gz -C /mysql/
[root@localhost ~]# chown -R mysql.mysql /mysql/
[root@localhost ~]# chmod -R 755 /mysql/
[root@localhost ~]# chown -R mysql.mysql /usr/src/mysql-5.7.18/
5、開始編譯安裝MySQL5.7.18
[root@localhost ~]# su - mysql
[mysql@localhost ~]$ cd /usr/src/mysql-5.7.18/
[mysql@localhost mysql-5.7.18]$cmake . -DCMAKE_INSTALL_PREFIX=/mysql/mysql5718 \
-DMYSQL_DATADIR=/mysql/data \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/mysql/boost_1_59_0
[mysql@localhost mysql-5.7.18]$ make -j 4 (并行4個進程同時進行編譯)
[mysql@localhost mysql-5.7.18]$ make install
6、初始化數(shù)據(jù)庫:
[mysql@localhost ~]$ /mysql/mysql5718/bin/mysqld --initialize --user=mysql --basedir=/mysql/mysql5718/ --datadir=/mysql/data/
---注意,在初始化數(shù)據(jù)庫會生成數(shù)據(jù)庫的默認密碼,這個密碼要記住,一會登錄數(shù)據(jù)庫要用
7、編輯my.cnf配置文件,啟動數(shù)據(jù)庫
[mysql@localhost ~]$ vim my.cnf (該配置文件僅供參考)
[client]
socket = /mysql/data/mysql.sock
default_character_set = utf8
[mysql]
socket=/mysql/data/mysql.sock
[mysqld]
server_id = 1607
port = 3306
basedir = /mysql/mysql5718/
datadir = /mysql/data/
socket = /mysql/data/mysql.sock
pid_file = /mysql/data/mysql.pid
log_error = /mysql/data/mysql_error.log
log_bin = /mysql/data/mysql_bin
relay_log = /mysql/data/relay_bin
character_set_server = utf8
collation_server = utf8_general_ci
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 8
innodb_log_file_size = 1G
innodb_log_files_in_group = 3
innodb_log_buffer_size = 24M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
innodb_flush_method = O_DIRECT
innodb_io_capacity = 200
innodb_io_capacity_max = 600
innodb_thread_concurrency = 0
innodb_autoinc_lock_mode = 2
innodb_lock_wait_timeout = 60
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_max_dirty_pages_pct = 80
innodb_autoextend_increment = 512
innodb_checksum_algorithm = NONE
innodb_doublewrite = 0
innodb_use_native_aio = 1
innodb_open_files = 8192
sync_binlog = 1
sync_relay_log = 1
relay_log_info_repository = TABLE
master_info_repository = TABLE
expire_logs_days = 10
binlog_format = ROW
transaction-isolation = READ-COMMITTED
concurrent_insert = 2
skip_slave_start = TRUE
back_log = 2000
thread_stack = 256k
thread_cache_size = 256
key_buffer_size = 256M
tmp_table_size = 64M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 2M
join_buffer_size = 2M
query_cache_size = 0
query_cache_type = 0
max_heap_table_size = 64M
binlog_cache_size = 2M
table_open_cache = 8192
max_allowed_packet = 64M
bulk_insert_buffer_size = 64M
max_connect_errors = 100000
max_connections = 500
connect_timeout = 300
wait_timeout = 86400
interactive_timeout = 86400
lower_case_table_names = 1
open_files_limit = 20480
skip_name_resolve
skip_external_locking
explicit_defaults_for_timestamp = TRUE
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysql@localhost ~]$ /mysql/mysql5718/bin/mysqld_safe --defaults-file=/mysql/data/my.cnf --user=mysql &
8、進入數(shù)據(jù)庫檢查:
[mysql@localhost ~]$ /mysql/mysql5718/bin/mysql -u root -p --socket=/mysql/data/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.18-log MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> set password='123456'; (因為剛才使用的密碼是個默認的登錄密碼,所以我們要修改)
mysql> flush privileges;
然后重新登錄數(shù)據(jù)庫,進行檢查:
[mysql@localhost ~]$ /mysql/mysql5718/bin/mysql -u root -p --socket=/mysql/data/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> \s
--------------
/mysql/mysql5718/bin/mysql Ver 14.14 Distrib 5.7.18, for linux-glibc2.5 (x86_64) using EditLine wrapper
Connection id: 7
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.18-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /mysql/data/mysql.sock
Uptime: 25 min 16 sec
Threads: 1 Questions: 19 Slow queries: 0 Opens: 110 Flush tables: 1 Open tables: 103 Queries per second avg: 0.012
--------------
mysql>
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。