myql 5.6 安裝
環境: centos 6.5 192.168.9.28 4核4G 虛擬機
一. 安裝編譯源碼所需要的工具和庫
[root@localhost ~]# yum -y install gcc gcc-c++ make ncurses-devel perl
[root@localhost soft]# ls
cmake-2.8.6.tar.gz mysql-5.6.35.tar.gz
[root@localhost soft]# tar xf cmake-2.8.6.tar.gz -C /usr/src
[root@localhost soft]# cd /usr/src/cmake-2.8.6/
[root@localhost cmake-2.8.6]# ls
bootstrap cmake_uninstall.cmake.in Docs
ChangeLog.manual CompileFlags.cmake doxygen.config
ChangeLog.txt configure Example
cmake.1 Copyright.txt Modules
CMakeCPack.cmake CTestConfig.cmake Readme.txt
CMakeCPackOptions.cmake.in CTestCustom.cmake.in Source
CMakeGraphVizOptions.cmake CTestCustom.ctest.in Templates
CMakeLists.txt DartConfig.cmake Tests
CMakeLogo.gif DartLocal.conf.in Utilities
[root@localhost cmake-2.8.6]# ./bootstrap
[root@localhost cmake-2.8.6]# make && make install
二.設置mysql用戶組和用戶
[root@localhost cmake-2.8.6]# groupadd mysql
[root@localhost cmake-2.8.6]# useradd -r -g mysql mysql
三. 新建mysql 所需要的數據目錄
[root@localhost cmake-2.8.6]# mkdir -p /usr/local/mysql
[root@localhost cmake-2.8.6]# mkdir -p /data/mysqldb
[root@localhost soft]# tar xf mysql-5.6.35.tar.gz -C /usr/src
[root@localhost soft]# cd /usr/src/mysql-5.6.35/
四.編譯安裝mysql
[root@localhost mysql-5.6.35]# cmake -DCMAK_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysqldb -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1
[root@localhost mysql-5.6.35]# make && make install
五.修改mysql目錄的所有者和屬組
[root@localhost mysql-5.6.35]# chown -R mysql.mysql /data/mysqldb/
[root@localhost mysql-5.6.35]# chown -R mysql.mysql /usr/local/mysql/
六. 導入mysql的配置文件,以下myql配置文件根據服務器的配置不同需要做出相應的更改。
也可以啟動mysql時,根據錯誤日誌內容做出相應的更改。
[root@localhost etc]# egrep -v "^$|^#" ./my.cnf
[mysqld]
datadir = /data/mysqldb
port = 3306
server_id = 11
autocommit = 0
character_set_server=utf8
max_allowed_packet = 52m
max-connections = 1000
interactive_timeout = 1800
wait_timeout = 1800
read_buffer_size = 16777216
read_rnd_buffer_size = 33554432
sort_buffer_size = 33554432
tmp_table_size = 67108864
tmpdir = /tmp
log-bin=mysql-bin
binlog-format = ROW
relay-log = mysql-relay-bin
log-slave-updates = 1
read_only = 0
sync_binlog = 1
plugin-load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
rpl-semi-sync-master-enabled = 1
rpl-semi-sync-slave-enabled = 1
slave-skip-errors = ddl_exist_errors
relay-log-info-repository = TABLE
relay_log_recovery = 1
master_info_repository = TABLE
log_error = error.log
slow_query_log = 1
slow_query_log_file = slow.log
log_queries_not_using_indexes = 1
log_slow_admin_statements = 1
log_slow_slave_statements = 1
log_throttle_queries_not_using_indexes = 10
expire_logs_days = 90
long_query_time = 2
min_examined_row_limit = 100
innodb_page_size = 16384
innodb_buffer_pool_size = 4G
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_lru_scan_depth = 2000
innodb_lock_wait_timeout = 5
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_method = O_DIRECT
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_flush_neighbors = 1
innodb_log_file_size = 4G
innodb_log_buffer_size = 16777216
innodb_purge_threads = 4
innodb_large_prefix = 1
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_flush_log_at_trx_commit=1
innodb_sort_buffer_size = 67108864
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
七. 初始化數據庫
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb
八. 復制mysql啟動腳本及加入PATH 路徑
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
[root@localhost mysql]# source /etc/profile
九 啟動myql 並加入開機自啟動
[root@localhost mysql]# /etc/init.d/mysqld start
[root@localhost mysql]# netstat -lnpt | grep 3306
tcp 0 0 :::3306 :::* LISTEN 1361/mysqld
註:在啟動mysql的時候,可能會遇到mysql 啟動報錯的問題,查看錯誤日誌報:
Fatal error: Can‘t open and lock privilege tables: Table ‘mysql.user‘ doesn‘t exist 解決方法:重新執行 第七步,在重新啟動mysql,錯誤日誌繼續報 [ERROR] Aborting,執行chown -R mysql:mysql /data/mysqldb/ chown -R mysql:mysql /usr/local/mysql/ ,在啟動mysql就可以了。
myql 5.6 安裝