CentOS6.5_64bit下編譯安裝MySQL-5.6.23

來源:互聯網
上載者:User

CentOS6.5_64bit下編譯安裝MySQL-5.6.23

CentOS6.5_64bit下編譯安裝MySQL-5.6.23

一、關閉防火牆
chkconfig iptables off
service iptables stop

二、下載mysql源碼包,mysql-5.6.23.tar.gz
下載時注意別選成其他的linux安裝包,不然編譯肯定報錯。選擇平台的下拉式清單裡選擇 Source Code,Select Platform: Source Code ,
下載 Generic Linux (Architecture Independent), Compressed TAR Archive。

三、添加使用者和組:
groupadd  mysql  #增加使用者組
useradd -g mysql mysql -s /usr/sbin/nologin

四、建立目錄及授權
mkdir -p /u01/my3306/data              #mysql資料目錄
mkdir -p /u01/my3306/log/iblog            #mysql innodb日誌
mkdir -p /u01/my3306/log/binlog          #mysql日誌
mkdir -p /u01/my3306/log/relaylog
mkdir -p /u01/my3306/run
mkdir -p /u01/my3306/tmp
chown -R mysql:mysql /u01/my3306
chmod -R 755 /u01/my3306

五、解壓
tar -zxvf mysql-5.6.23.tar.gz
cd mysql-5.6.23

六、編譯並安裝
cmake \
-DCMAKE_INSTALL_PREFIX=/u01/my3306 \
-DINSTALL_DATADIR=/u01/my3306/data  \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_SSL=yes \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DSYSCONFDIR=/etc \
-DWITH_READLINE=on


make
make install


七、修改設定檔my.cnf參數
cp /u01/my3306/support-files/my-default.cnf  /u01/my3306/my.cnf

vi  /u01/my3306/my.cnf  ---添加


[client]
port = 3306
socket =/u01/my3306/run/mysql.sock

[mysql]
no-auto-rehash
pid_file=/u01/my3306/run/mysqld.pid

[mysqld]
## disable autocommit
autocommit=0
general_log=off
explicit_defaults_for_timestamp=true

# system
basedir=/u01/my3306
datadir=/u01/my3306/data/
max_allowed_packet=134217728
max_connections=8192
max_user_connections=8000
open_files_limit=65535
pid_file=/u01/my3306/run/mysqld.pid
port=3306
server_id=1
skip_name_resolve=ON
socket=/u01/my3306/run/mysql.sock
tmpdir=/u01/my3306/tmp

# binlog
binlog_cache_size=32768
binlog_format=row
expire_logs_days=7
log_bin=/u01/my3306/log/binlog
log_slave_updates=ON
max_binlog_cache_size=2147483648
max_binlog_size=524288000
sync_binlog=100

#relay
relay_log=/u01/my3306/log/relaylog
relay_log_index=/u01/my3306/log/relay.index
relay_log_info_file=/u01/my3306/log/relay-log.info

# LOGGING #
log_error                      = /u01/my3306/log/alert.log
log_queries_not_using_indexes  = 1
slow_query_log                = 1
slow_query_log_file            = /u01/my3306/log/slow.log
log_slave_updates=ON
log_slow_admin_statements=1
long_query_time=1

#slave#
slave_skip_errors=OFF
log_slave_updates=ON

# innodb #
innodb_log_group_home_dir=/u01/my3306/log/iblog
innodb_data_home_dir=/u01/my3306/log/iblog
innodb_adaptive_flushing=1
innodb_additional_mem_pool_size=20M
innodb_buffer_pool_instances=8
innodb_change_buffering=inserts
innodb_data_file_path=ibdata1:32M;ibdata2:16M:autoextend
innodb_flush_method            = O_DIRECT
innodb_log_files_in_group      = 4
innodb_log_file_size          = 32M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table          = 1
innodb_buffer_pool_size        = 128M
innodb_file_format=Barracuda
innodb_file_io_threads=4
innodb_flush_neighbors=0
innodb_io_capacity=200
innodb_lock_wait_timeout=5
innodb_log_buffer_size=64M
innodb_lru_scan_depth=2048
innodb_max_dirty_pages_pct=60
innodb_old_blocks_time=1000
innodb_online_alter_log_max_size=200M
innodb_open_files=200
innodb_print_all_deadlocks=1
innodb_purge_threads=4
innodb_read_ahead_threshold=0
innodb_read_io_threads=8
innodb_rollback_on_timeout=0
innodb_sort_buffer_size=2M
innodb_spin_wait_delay=6
innodb_stats_on_metadata=0
innodb_strict_mode=1
innodb_sync_array_size=256
innodb_sync_spin_loops=30
innodb_thread_concurrency=64
innodb_use_native_aio=0
innodb_write_io_threads=8
innodb_support_xa=1

[mysqld_safe]
datadir=/u01/my3306/data/

八、執行MySQL安裝指令碼
./scripts/mysql_install_db  --defaults-file=/u01/my3306/my.cnf  --user=mysql --datadir=/u01/my3306/data
   
說明:defaults-file表示指定預設的設定檔,如果不指定,系統預設的優先順序是先使用/etc/my.cnf作為mysql的設定檔,那之前make的那些參數就白設定了.

九、啟動mysql
mysqld_safe --defaults-file=/u01/app/mysql/data/mysql3306/my.cnf --user=mysql &

十、登入MySQL
mysql -h127.0.0.1 -uroot -P3306

--------------------------------------分割線 --------------------------------------

Ubuntu 14.04下安裝MySQL

《MySQL權威指南(原書第2版)》清晰中文掃描版 PDF

Ubuntu 14.04 LTS 安裝 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

Ubuntu 14.04下搭建MySQL主從伺服器

Ubuntu 12.04 LTS 構建高可用分布式 MySQL 叢集

Ubuntu 12.04下原始碼安裝MySQL5.6以及Python-MySQLdb

MySQL-5.5.38通用二進位安裝

--------------------------------------分割線 --------------------------------------

本文永久更新連結地址:

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.