MySQL 5.6原始碼編譯安裝流程
(1) 關閉防火牆和Selinux
[root@localhost ~]# service iptables status
iptables: Firewall is not running.
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
[root@localhost ~]# chkconfig iptables off
(2) 下載MySQL 5.6原始碼包
https://dev.mysql.com/downloads/mysql/5.6.html#downloads
下載完畢後,上傳原始碼包到伺服器上
(3) 新增使用者和組
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -d /home/mysql -g mysql -m mysql
[root@localhost ~]# passwd mysql
配置環境變數
[root@localhost ~]# su - mysql
[mysql@localhost ~]$ vim .bash_profile
[mysql@localhost ~]$ cat .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:/mysql_software_56/bin
export PATH
(4) 建立相關目錄
建立軟體目錄
[root@localhost ~]# mkdir /mysql_software_56
建立資料檔案目錄和日誌目錄
[root@localhost ~]# mkdir -p /my3306/data
[root@localhost ~]# mkdir -p /my3306/log/iblog
[root@localhost ~]# mkdir -p /my3306/log/binlog
建立存放Pid和臨時檔案目錄
[root@localhost ~]# mkdir -p /my3306/run
[root@localhost ~]# mkdir -p /my3306/tmp
更改許可權
[root@localhost ~]# chown -R mysql:mysql /my3306
[root@localhost ~]# chmod -R 755 /my3306
(5) 解壓MySQL 5.6安裝包並安裝cmake
[root@localhost ~]# cd /install/
[root@localhost install]# tar xvfz mysql-5.6.37.tar.gz
[root@localhost install]# yum install -y cmake gcc gcc-c++ ncurses-devel zlib libxml openssl
(6) 編譯並安裝
[root@localhost install]# cd mysql-5.6.37
[root@localhost mysql-5.6.37]# cmake . -DCMAKE_INSTALL_PREFIX=/mysql_software_56 \
> -DINSTALL_DATADIR=/my3306/data \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DEXTRA_CHARSETS=all \
> -DWITH_SSL=yes \
> -DWITH_EMBEDDED_SERVER=1 \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_FEDERATED_STORAGE_ENGINE=1 \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
> -DWITH_PARTITION_STORAGE_ENGINE=1 \
> -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
> -DMYSQL_UNIX_ADDR=/my3306/run/mysql.sock \
> -DMYSQL_TCP_PORT=3306 \
> -DSYSCONFDIR=/etc \
> -DENABLED_LOCAL_INFILE=ON \
> -DCOMPILATION_COMMENT='MySQL 5.6 production environment' \
> -DWITH_READLINE=ON
[root@localhost mysql-5.6.37]# make
[root@localhost mysql-5.6.37]# make install
(7) 配置MySQL引數檔案
[root@localhost tmp]# cat /etc/my_5.6_3306.cnf
[client]
port=3306
socket=/my3306/run/mysql.sock
[mysql]
pid_file=/my3306/run/mysqld.pid
[mysqld]
autocommit=1
general_log=off
explicit_defaults_for_timestamp=true
# system
basedir=/mysql_software_56
datadir=/my3306/data
max_allowed_packet=1g
max_connections=3000
max_user_connections=2800
open_files_limit=65535
pid_file=/my3306/run/mysqld.pid
port=3306
server_id=101
skip_name_resolve=ON
socket=/my3306/run/mysql.sock
tmpdir=/my3306/tmp
#binlog
log_bin=/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=/my3306/log/error.log
slow_query_log_file=/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=/my3306/log/relaylog
relay_log_index=/my3306/log/relay.index
relay_log_info_file=/my3306/log/relay-log.info
#slave
slave_load_tmpdir= /my3306/tmp
slave_skip_errors=OFF
#innodb
innodb_data_home_dir=/my3306/log/iblog
innodb_log_group_home_dir=/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=100M
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]
datadir=/my3306/data
(8) 初始化MySQL
[root@localhost mysql_software_56]# /mysql_software_56/scripts/mysql_install_db --defaults-file=/etc/my_5.6_3306.cnf --datadir=/my3306/data/ --user=mysql
Installing MySQL system tables...2017-07-29 02:01:18 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-07-29 02:01:18 0 [Note] ./bin/mysqld (mysqld 5.6.37-log) starting as process 50198 ...
OK
Filling help tables...2017-07-29 02:03:47 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-07-29 02:03:47 0 [Note] ./bin/mysqld (mysqld 5.6.37-log) starting as process 50239 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/mysql_software_56/bin/mysqladmin -u root password 'new-password'
/mysql_software_56/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/mysql_software_56/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /mysql_software_56/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at
The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at
New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
啟動資料庫
[root@localhost mysql_software_56]# /mysql_software_56/bin/mysqld_safe --defaults-file=/etc/my_5.6_3306.cnf --user=mysql &
[1] 50284
[root@localhost mysql_software_56]# 170729 02:07:56 mysqld_safe Logging to '/my3306/log/error.log'.
170729 02:07:56 mysqld_safe Starting mysqld daemon with databases from /my3306/data
[root@localhost ~]# service iptables status
iptables: Firewall is not running.
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
[root@localhost ~]# chkconfig iptables off
(2) 下載MySQL 5.6原始碼包
https://dev.mysql.com/downloads/mysql/5.6.html#downloads
下載完畢後,上傳原始碼包到伺服器上
(3) 新增使用者和組
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -d /home/mysql -g mysql -m mysql
[root@localhost ~]# passwd mysql
配置環境變數
[root@localhost ~]# su - mysql
[mysql@localhost ~]$ vim .bash_profile
[mysql@localhost ~]$ cat .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:/mysql_software_56/bin
export PATH
(4) 建立相關目錄
建立軟體目錄
[root@localhost ~]# mkdir /mysql_software_56
建立資料檔案目錄和日誌目錄
[root@localhost ~]# mkdir -p /my3306/data
[root@localhost ~]# mkdir -p /my3306/log/iblog
[root@localhost ~]# mkdir -p /my3306/log/binlog
建立存放Pid和臨時檔案目錄
[root@localhost ~]# mkdir -p /my3306/run
[root@localhost ~]# mkdir -p /my3306/tmp
更改許可權
[root@localhost ~]# chown -R mysql:mysql /my3306
[root@localhost ~]# chmod -R 755 /my3306
(5) 解壓MySQL 5.6安裝包並安裝cmake
[root@localhost ~]# cd /install/
[root@localhost install]# tar xvfz mysql-5.6.37.tar.gz
[root@localhost install]# yum install -y cmake gcc gcc-c++ ncurses-devel zlib libxml openssl
(6) 編譯並安裝
[root@localhost install]# cd mysql-5.6.37
[root@localhost mysql-5.6.37]# cmake . -DCMAKE_INSTALL_PREFIX=/mysql_software_56 \
> -DINSTALL_DATADIR=/my3306/data \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DEXTRA_CHARSETS=all \
> -DWITH_SSL=yes \
> -DWITH_EMBEDDED_SERVER=1 \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_FEDERATED_STORAGE_ENGINE=1 \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
> -DWITH_PARTITION_STORAGE_ENGINE=1 \
> -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
> -DMYSQL_UNIX_ADDR=/my3306/run/mysql.sock \
> -DMYSQL_TCP_PORT=3306 \
> -DSYSCONFDIR=/etc \
> -DENABLED_LOCAL_INFILE=ON \
> -DCOMPILATION_COMMENT='MySQL 5.6 production environment' \
> -DWITH_READLINE=ON
[root@localhost mysql-5.6.37]# make
[root@localhost mysql-5.6.37]# make install
(7) 配置MySQL引數檔案
[root@localhost tmp]# cat /etc/my_5.6_3306.cnf
[client]
port=3306
socket=/my3306/run/mysql.sock
[mysql]
pid_file=/my3306/run/mysqld.pid
[mysqld]
autocommit=1
general_log=off
explicit_defaults_for_timestamp=true
# system
basedir=/mysql_software_56
datadir=/my3306/data
max_allowed_packet=1g
max_connections=3000
max_user_connections=2800
open_files_limit=65535
pid_file=/my3306/run/mysqld.pid
port=3306
server_id=101
skip_name_resolve=ON
socket=/my3306/run/mysql.sock
tmpdir=/my3306/tmp
#binlog
log_bin=/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=/my3306/log/error.log
slow_query_log_file=/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=/my3306/log/relaylog
relay_log_index=/my3306/log/relay.index
relay_log_info_file=/my3306/log/relay-log.info
#slave
slave_load_tmpdir= /my3306/tmp
slave_skip_errors=OFF
#innodb
innodb_data_home_dir=/my3306/log/iblog
innodb_log_group_home_dir=/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=100M
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]
datadir=/my3306/data
(8) 初始化MySQL
[root@localhost mysql_software_56]# /mysql_software_56/scripts/mysql_install_db --defaults-file=/etc/my_5.6_3306.cnf --datadir=/my3306/data/ --user=mysql
Installing MySQL system tables...2017-07-29 02:01:18 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-07-29 02:01:18 0 [Note] ./bin/mysqld (mysqld 5.6.37-log) starting as process 50198 ...
OK
Filling help tables...2017-07-29 02:03:47 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-07-29 02:03:47 0 [Note] ./bin/mysqld (mysqld 5.6.37-log) starting as process 50239 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/mysql_software_56/bin/mysqladmin -u root password 'new-password'
/mysql_software_56/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/mysql_software_56/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /mysql_software_56/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at
The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at
New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
啟動資料庫
[root@localhost mysql_software_56]# /mysql_software_56/bin/mysqld_safe --defaults-file=/etc/my_5.6_3306.cnf --user=mysql &
[1] 50284
[root@localhost mysql_software_56]# 170729 02:07:56 mysqld_safe Logging to '/my3306/log/error.log'.
170729 02:07:56 mysqld_safe Starting mysqld daemon with databases from /my3306/data
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2142773/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Mysql5.6 for Centos6.5原始碼編譯安裝MySqlCentOS原始碼編譯
- 【轉】MySQL原始碼編譯安裝MySql原始碼編譯
- MySQL5.7.16原始碼編譯安裝MySql原始碼編譯
- 阿里雲mysql原始碼編譯安裝阿里MySql原始碼編譯
- 原始碼編譯安裝Redis原始碼編譯Redis
- 在VMware已安裝的CentOS7.9上編譯安裝mysql5.6CentOS編譯MySql
- 原始碼編譯安裝的原理原始碼編譯
- Ubuntu 16.04下 Mysql5.7.17原始碼編譯與安裝UbuntuMySql原始碼編譯
- GDB 除錯 Mysql 實戰(一)原始碼編譯安裝除錯MySql原始碼編譯
- 基於Linux的MySQL5.7原始碼編譯安裝LinuxMySql原始碼編譯
- nginx原始碼編譯安裝(詳解)Nginx原始碼編譯
- linux-原始碼的編譯安裝和解除安裝Linux原始碼編譯
- Greenplum_原始碼編譯安裝和RPM包安裝原始碼編譯
- CentOS 7.4 環境下原始碼編譯(多例項)安裝 Mysql 5.7.26CentOS原始碼編譯MySql
- 【MySQL安裝】Linux下安裝MySQL(預編譯)MySqlLinux編譯
- CentOS 安裝 mysql 5.6CentOSMySql
- Windows 安裝 MySQL 5.6WindowsMySql
- Linux環境PostGIS原始碼編譯安裝Linux原始碼編譯
- 04 原始碼編譯安裝與介紹原始碼編譯
- PostgreSQL原始碼學習 win10原始碼編譯安裝SQL原始碼Win10編譯
- CentOS6.9原始碼編譯安裝nginx+php7+mysql環境CentOS原始碼編譯NginxPHPMySql
- 龍芯麒麟原始碼編譯MySQL生成軟體包進行安裝原始碼編譯MySql
- Ubuntu 16.04原始碼編譯安裝Apache 2.4.25教程Ubuntu原始碼編譯Apache
- Centos7下原始碼編譯安裝apacheCentOS原始碼編譯Apache
- Linux安裝Mysql5.6LinuxMySql
- 龍芯原始碼編譯MySQL原始碼編譯MySql
- 編譯安裝nginx-php-mysql編譯NginxPHPMySql
- 如何編譯安裝MySQL8.0編譯MySql
- [環境搭建] 透過原始碼編譯安裝 Redis原始碼編譯Redis
- Nginx1.19 php8.0 原始碼編譯安裝NginxPHP原始碼編譯
- Centos7安裝(四)抓包工具wireshark原始碼編譯安裝CentOS原始碼編譯
- Windows 安裝並配置 MySQL 5.6WindowsMySql
- 連網安裝mysql與原始碼安裝mysqlMySql原始碼
- centOS 7 離線安裝 MySQL 5.6 完美安裝CentOSMySql
- MySQL 5.7.28 原始碼安裝MySql原始碼
- 麒麟系統開發筆記(三):從Qt原始碼編譯安裝之編譯安裝Qt5.12筆記QT原始碼編譯
- CentOS 7.4 環境下原始碼編譯安裝 postgreSQL 11.4CentOS原始碼編譯SQL
- Ubuntu20.04 從原始碼編譯安裝 python3.10Ubuntu原始碼編譯Python
- Cnetos7編譯安裝MySQL教程。編譯MySql