Mysql5.6 for Centos6.5原始碼編譯安裝
## 說明 不同伺服器需要改變 server_id ,同一臺機器上需要改變 port
1. 關閉防火牆
[root@mysql ~]# service iptables status --檢視防火牆狀態
[root@mysql ~]# service iptables stop --關閉防火牆
[root@mysql ~]# chkconfig iptables off --永久關閉
[root@mysql ~]# vim /etc/sysconfig/selinux
SELINUX=disabled
2. 配置sysctl.conf
生產環境下建議根據情況配置,虛擬機器安裝可以不設定
3. 檢查作業系統上是否已經安裝了mysql,如果有進行解除安裝
[root@mysql yum.repos.d]# rpm -qa |grep mysql
[root@mysql yum.repos.d]# yum remove mysql
4. 下載mysql原始碼包
https://dev.mysql.com/downloads/file/?id=469012
5. 新增使用者和組
[root@mysql u01]# userdel -r mysql --刪除原先的mysql使用者 -r會刪掉附帶的group
[root@mysql u01]# groupadd mysql
[root@mysql u01]# useradd -d /home/mysql -g mysql -m mysql
[root@mysql u01]# passwd mysql
Changing password for user mysql.
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.
[root@mysql u01]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)
6. 配置mysql環境變數
[mysql@mysql ~]$ vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/u01/my3306/bin
export PATH
[mysql@mysql ~]$ source .bash_profile
7. 建立目錄及授權
[root@mysql u01]# cd /u01
[root@mysql u01]# mkdir -p /u01/my3306/data
[root@mysql u01]# mkdir -p /u01/my3306/log/iblog
[root@mysql u01]# mkdir -p /u01/my3306/log/binlog
[root@mysql u01]# mkdir -p /u01/my3306/run
[root@mysql u01]# mkdir -p /u01/my3306/tmp
[root@mysql u01]# chown -R mysql:mysql /u01/my3306
[root@mysql u01]# chmod 755 /u01/my3306
8. 解壓mysql
[root@mysql u01]# tar -xzvf mysql-5.6.36.tar.gz
9. 配置yum源,安裝cmakle及一些必備的包,要求2.6版本及以上
yum install -y cmake gcc gcc-c++ ncurses-devel bison zlib libxml openssl
10. 編譯並安裝
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_UNIX_ADDR=/u01/my3306/run/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DSYSCONFDIR=/etc \
-DWITH_READLINE=on
[root@mysql mysql-5.6.36]# cd mysql-5.6.36
[root@mysql mysql-5.6.36]# 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_UNIX_ADDR=/u01/my3306/run/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DSYSCONFDIR=/etc -DWITH_READLINE=on
[root@mysql mysql-5.6.36]# make
[root@mysql mysql-5.6.36]# make install
11. 配置mysql引數
[root@mysql my3306]# pwd
/u01/my3306
[root@mysql my3306]# cat my.cnf
[client]
port=3306
socket=/u01/my3306/mysql.sock
[mysql]
pid_file=/u01/my3306/run/mysqld.pid
[mysqld]
autocommit=1
general_log=off
explicit_defaults_for_timestamp=true
# system
basedir=/u01/my3306
datadir=/u01/my3306/data
max_allowed_packet=1g
max_connections=3000
max_user_connections=2800
open_files_limit=65535
pid_file=/u01/my3306/run/mysqld.pid
port=3306
server_id=101
skip_name_resolve=ON
socket=/u01/my3306/run/mysql.sock
tmpdir=/u01/my3306/tmp
#binlog
log_bin=/u01/my3306/log/binlog/binlog
binlog_cache_size=32768
binlog_format=row
expire_logs_days=7
log_slave_updates=ON
max_binlog_cache_size=2147483648
max_binlog_size=524288000
sync_binlog=100
#logging
log_error=/u01/my3306/log/error.log
slow_query_log_file=/u01/my3306/log/slow.log
log_queries_not_using_indexes=0
slow_query_log=1
log_slave_updates=ON
log_slow_admin_statements=1
long_query_time=1
#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
#slave
slave_load_tmpdir=/u01/my3306/tmp
slave_skip_errors=OFF
#innodb
innodb_data_home_dir=/u01/my3306/log/iblog
innodb_log_group_home_dir=/u01/my3306/log/iblog
innodb_adaptive_flushing=ON
innodb_adaptive_hash_index=ON
innodb_autoinc_lock_mode=1
innodb_buffer_pool_instances=8
#default
innodb_change_buffering=inserts
innodb_checksums=ON
innodb_buffer_pool_size= 128M
innodb_data_file_path=ibdata1:32M;ibdata2:16M:autoextend
innodb_doublewrite=ON
innodb_file_format=Barracuda
innodb_file_per_table=ON
innodb_flush_log_at_trx_commit=1
innodb_flush_method=O_DIRECT
innodb_io_capacity=1000
innodb_lock_wait_timeout=10
innodb_log_buffer_size=67108864
innodb_log_file_size=1048576000
innodb_log_files_in_group=4
innodb_max_dirty_pages_pct=60
innodb_open_files=60000
innodb_purge_threads=1
innodb_read_io_threads=4
innodb_stats_on_metadata=OFF
innodb_support_xa=ON
innodb_use_native_aio=OFF
innodb_write_io_threads=10
[mysqld_safe]
[root@mysql my3306]# chown -R mysql:mysql /u01/my3306
12. 初始化mysql指令碼
[root@mysql my3306]# ./scripts/mysql_install_db --defaults-file=/u01/my3306/my.cnf --datadir=/u01/my3306/data --user=mysql
13. 啟動mysql
[mysql@mysql bin]$ ./mysqld_safe --defaults-file=/u01/my3306/my.cnf --user=mysql &
[1] 17237
[mysql@mysql bin]$ 170612 06:37:02 mysqld_safe Logging to '/u01/my3306/log/error.log'.
170612 06:37:02 mysqld_safe Starting mysqld daemon with databases from /u01/my3306/data
[mysql@mysql bin]$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.36-log Source distribution
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>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.10 sec)
## 說明 不同伺服器需要改變 server_id ,同一臺機器上需要改變 port
1. 關閉防火牆
[root@mysql ~]# service iptables status --檢視防火牆狀態
[root@mysql ~]# service iptables stop --關閉防火牆
[root@mysql ~]# chkconfig iptables off --永久關閉
[root@mysql ~]# vim /etc/sysconfig/selinux
SELINUX=disabled
2. 配置sysctl.conf
生產環境下建議根據情況配置,虛擬機器安裝可以不設定
3. 檢查作業系統上是否已經安裝了mysql,如果有進行解除安裝
[root@mysql yum.repos.d]# rpm -qa |grep mysql
[root@mysql yum.repos.d]# yum remove mysql
4. 下載mysql原始碼包
https://dev.mysql.com/downloads/file/?id=469012
5. 新增使用者和組
[root@mysql u01]# userdel -r mysql --刪除原先的mysql使用者 -r會刪掉附帶的group
[root@mysql u01]# groupadd mysql
[root@mysql u01]# useradd -d /home/mysql -g mysql -m mysql
[root@mysql u01]# passwd mysql
Changing password for user mysql.
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.
[root@mysql u01]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)
6. 配置mysql環境變數
[mysql@mysql ~]$ vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/u01/my3306/bin
export PATH
[mysql@mysql ~]$ source .bash_profile
7. 建立目錄及授權
[root@mysql u01]# cd /u01
[root@mysql u01]# mkdir -p /u01/my3306/data
[root@mysql u01]# mkdir -p /u01/my3306/log/iblog
[root@mysql u01]# mkdir -p /u01/my3306/log/binlog
[root@mysql u01]# mkdir -p /u01/my3306/run
[root@mysql u01]# mkdir -p /u01/my3306/tmp
[root@mysql u01]# chown -R mysql:mysql /u01/my3306
[root@mysql u01]# chmod 755 /u01/my3306
8. 解壓mysql
[root@mysql u01]# tar -xzvf mysql-5.6.36.tar.gz
9. 配置yum源,安裝cmakle及一些必備的包,要求2.6版本及以上
yum install -y cmake gcc gcc-c++ ncurses-devel bison zlib libxml openssl
10. 編譯並安裝
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_UNIX_ADDR=/u01/my3306/run/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DSYSCONFDIR=/etc \
-DWITH_READLINE=on
[root@mysql mysql-5.6.36]# cd mysql-5.6.36
[root@mysql mysql-5.6.36]# 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_UNIX_ADDR=/u01/my3306/run/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DSYSCONFDIR=/etc -DWITH_READLINE=on
[root@mysql mysql-5.6.36]# make
[root@mysql mysql-5.6.36]# make install
11. 配置mysql引數
[root@mysql my3306]# pwd
/u01/my3306
[root@mysql my3306]# cat my.cnf
[client]
port=3306
socket=/u01/my3306/mysql.sock
[mysql]
pid_file=/u01/my3306/run/mysqld.pid
[mysqld]
autocommit=1
general_log=off
explicit_defaults_for_timestamp=true
# system
basedir=/u01/my3306
datadir=/u01/my3306/data
max_allowed_packet=1g
max_connections=3000
max_user_connections=2800
open_files_limit=65535
pid_file=/u01/my3306/run/mysqld.pid
port=3306
server_id=101
skip_name_resolve=ON
socket=/u01/my3306/run/mysql.sock
tmpdir=/u01/my3306/tmp
#binlog
log_bin=/u01/my3306/log/binlog/binlog
binlog_cache_size=32768
binlog_format=row
expire_logs_days=7
log_slave_updates=ON
max_binlog_cache_size=2147483648
max_binlog_size=524288000
sync_binlog=100
#logging
log_error=/u01/my3306/log/error.log
slow_query_log_file=/u01/my3306/log/slow.log
log_queries_not_using_indexes=0
slow_query_log=1
log_slave_updates=ON
log_slow_admin_statements=1
long_query_time=1
#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
#slave
slave_load_tmpdir=/u01/my3306/tmp
slave_skip_errors=OFF
#innodb
innodb_data_home_dir=/u01/my3306/log/iblog
innodb_log_group_home_dir=/u01/my3306/log/iblog
innodb_adaptive_flushing=ON
innodb_adaptive_hash_index=ON
innodb_autoinc_lock_mode=1
innodb_buffer_pool_instances=8
#default
innodb_change_buffering=inserts
innodb_checksums=ON
innodb_buffer_pool_size= 128M
innodb_data_file_path=ibdata1:32M;ibdata2:16M:autoextend
innodb_doublewrite=ON
innodb_file_format=Barracuda
innodb_file_per_table=ON
innodb_flush_log_at_trx_commit=1
innodb_flush_method=O_DIRECT
innodb_io_capacity=1000
innodb_lock_wait_timeout=10
innodb_log_buffer_size=67108864
innodb_log_file_size=1048576000
innodb_log_files_in_group=4
innodb_max_dirty_pages_pct=60
innodb_open_files=60000
innodb_purge_threads=1
innodb_read_io_threads=4
innodb_stats_on_metadata=OFF
innodb_support_xa=ON
innodb_use_native_aio=OFF
innodb_write_io_threads=10
[mysqld_safe]
[root@mysql my3306]# chown -R mysql:mysql /u01/my3306
12. 初始化mysql指令碼
[root@mysql my3306]# ./scripts/mysql_install_db --defaults-file=/u01/my3306/my.cnf --datadir=/u01/my3306/data --user=mysql
13. 啟動mysql
[mysql@mysql bin]$ ./mysqld_safe --defaults-file=/u01/my3306/my.cnf --user=mysql &
[1] 17237
[mysql@mysql bin]$ 170612 06:37:02 mysqld_safe Logging to '/u01/my3306/log/error.log'.
170612 06:37:02 mysqld_safe Starting mysqld daemon with databases from /u01/my3306/data
[mysql@mysql bin]$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.36-log Source distribution
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>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.10 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31383567/viewspace-2212966/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 原始碼編譯安裝Redis原始碼編譯Redis
- 原始碼編譯安裝的原理原始碼編譯
- 【轉】MySQL原始碼編譯安裝MySql原始碼編譯
- MySQL5.7.16原始碼編譯安裝MySql原始碼編譯
- 阿里雲mysql原始碼編譯安裝阿里MySql原始碼編譯
- nginx原始碼編譯安裝(詳解)Nginx原始碼編譯
- 在VMware已安裝的CentOS7.9上編譯安裝mysql5.6CentOS編譯MySql
- linux-原始碼的編譯安裝和解除安裝Linux原始碼編譯
- Greenplum_原始碼編譯安裝和RPM包安裝原始碼編譯
- Linux環境PostGIS原始碼編譯安裝Linux原始碼編譯
- 04 原始碼編譯安裝與介紹原始碼編譯
- PostgreSQL原始碼學習 win10原始碼編譯安裝SQL原始碼Win10編譯
- Ubuntu 16.04原始碼編譯安裝Apache 2.4.25教程Ubuntu原始碼編譯Apache
- Centos7下原始碼編譯安裝apacheCentOS原始碼編譯Apache
- [環境搭建] 透過原始碼編譯安裝 Redis原始碼編譯Redis
- Nginx1.19 php8.0 原始碼編譯安裝NginxPHP原始碼編譯
- Centos7安裝(四)抓包工具wireshark原始碼編譯安裝CentOS原始碼編譯
- 麒麟系統開發筆記(三):從Qt原始碼編譯安裝之編譯安裝Qt5.12筆記QT原始碼編譯
- Ubuntu 16.04下 Mysql5.7.17原始碼編譯與安裝UbuntuMySql原始碼編譯
- CentOS 7.4 環境下原始碼編譯安裝 postgreSQL 11.4CentOS原始碼編譯SQL
- GDB 除錯 Mysql 實戰(一)原始碼編譯安裝除錯MySql原始碼編譯
- Ubuntu20.04 從原始碼編譯安裝 python3.10Ubuntu原始碼編譯Python
- 基於Linux的MySQL5.7原始碼編譯安裝LinuxMySql原始碼編譯
- Linux環境下, 原始碼編譯安裝詳解 (編譯CMake 3.15 和 gcc 5.3.0 為例)Linux原始碼編譯GC
- Jtti:美國Linux伺服器原始碼編譯的安裝方式JttiLinux伺服器原始碼編譯
- CentOS 7.4 環境下原始碼編譯(多例項)安裝 Mysql 5.7.26CentOS原始碼編譯MySql
- Elam的caffe筆記之配置篇(一):CentOS6.5編譯安裝gcc4.8.2筆記CentOS編譯GC
- Linux安裝Mysql5.6LinuxMySql
- 編譯安裝zabbix編譯
- 安裝編譯ffmpeg編譯
- Griffin編譯安裝編譯
- 編譯安裝nmon編譯
- swoole 編譯安裝編譯
- apache編譯安裝Apache編譯
- CentOS6.5安裝pipCentOS
- CentOS6.5 安裝opensslCentOS
- CentOS6.5安裝ScrapyCentOS
- centos7:從原始碼編譯安裝 nfs-ganesha v2.8.4CentOS原始碼編譯NFS