[MySQL] install bitsCN.com in Linux MySQL-5.6 source code
[MySQL] Linux MySQL-5.6 source code installation
This article describes how to install MySQL 5.6 in the source code of centos. the centos version is 5.8.
1) first, you need to go to the MySQL official website to download the Source Code tar package. click MySQL Community Server and select Source Code. the Source Code package is not large, only about 34 MB.
Note: The following operations are not described as follows.
2) install cmake first (after mysql5.5, the source code must be compiled through cmake)
[Plain]
# Yum install cmake
Make sure that the latest versions of the following packages are installed:
Ncurses
Ncurses-devel
3) add MySQL User groups and users
[Plain]
# Groupadd mysql
# Useradd mysql
4) create the MySQL software installation directory and data storage directory
[Plain]
Mkdir-p/opt/mysql # MySQL installation directory
Chown-R mysql: mysql/opt/mysql
Mkdir-p/data/mysql # MySQL data storage directory
Mkdir-p/data/mysql/data # store data
Mkdir-p/data/mysql/log # store logs
Mkdir-p/data/mysql/tmp # store temporary files
Chown-R mysql: mysql/data/mysql
5) compile and install MySQL using cmake
[Plain]
Tar zxvf mysql-5.6.13.tar.gz
Cd mysql-5.6.13
Cmake.-DCMAKE_INSTALL_PREFIX =/opt/mysql-packages =/data/mysql-DSYSCONFDIR =/opt/mysql-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = bytes-dextra_sets char= all-items = 1
Make
Make install
Parameter description:
-DCMAKE_INSTALL_PREFIX =/opt/mysql // specify the installation directory
-DINSTALL_DATADIR =/data/mysql // specify the data storage directory
-DSYSCONFDIR =/opt/mysql // specify the configuration file directory (the configuration file in this example is/opt/mysql/my. cnf)
-DDEFAULT_CHARSET = utf8 // specify the character set
-DDEFAULT_COLLATION = utf8_general_ci // specify the verification character
-DEXTRA_CHARSETS = all // install all extended character sets
-DENABLED_LOCAL_INFILE = 1 // allow local data import
After the preceding steps are completed, the MySQL software is successfully installed in the/opt/mysql directory.
7) edit the configuration file my. cnf
[Plain]
[Client]
Socket =/opt/mysql/run/mysql. sock
[Innotop]
Socket =/opt/mysql/run/mysql. sock
[Mysql]
Prompt = // u @ // d // r: // m: // s>
No-auto-rehash
[Mysqld_safe]
Pid-file =/opt/mysql/run/mysqld. pid
[Mysqld]
#### Baes dir ####
Basedir =/opt/mysql
Datadir =/data/mysql/data
Tmpdir =/data/mysql/tmp
Socket =/opt/mysql/run/mysql. sock
#### Base configure info ####
Port = 3306
Skip-name-resolve
Old_passwords = 0
Lower_case_table_names = 1
Open_files_limit = 65535
Read_rnd_buffer_size = 5 M
Max_allowed_packet = 24 M
Max_connect_errorrs = 50000
Max_connections = 1000
Max_user_connection= 950
Thread_cache_size = 64
Table_open_cache = 1024
Thread _ stack = 262144
Wait_timeout = 864000
#### Log info ####
Log-error =/data/mysql/log/alert. log
Slow_query_log = 1
Slow_query_log_file =/data/mysql/log/slow. log
Log-slow-admin-statements
Long_query_time = 0.1.
Slow_launch_time = 1
#### Binary log & Relay log ####
Binlog_format = 'mixed'
Log-bin =/data/mysql/log/mysql-bin
Log-slave-updates = 1
Relay-log =/data/mysql/log/mysqld-relay-bin
Relay-log-index =/data/mysql/log/mysqld-relay-bin.index
Master-info-file =/data/mysql/log/master.info
Relay-log-info-file =/data/mysql/log/relay-log.info
Max_binlog_size = 500 M
Max_binlog_cache_size = 2G
#### Query cache ####
Query_cache_size = 100 M
Query_cache_limit = 1 K
Query_cache_min_res_unit = 1 K
Query_cache_type = 2
# Myisam
Concurrent_insert = 2
Key_buffer_size = 100 M
Sort_buffer_size = 100 K
Join_buffer_size = 100 K
Read_buffer_size = 1 M
Myisam_sort_buffer_size = 100 M
# Innodb plugin
# Innodb
Default-storage-engine = INNODB
Innodb_flush_method = O_DIRECT
Innodb_file_per_table = 1
Innodb_open_files = 60000
Innodb_flush_log_at_trx_commit = 2
Innodb_lock_wait_timeout = 100
Innodb_additional_mem_pool_size = 20 M
Innodb_buffer_pool_size = 16G
Innodb_log_buffer_size = 400 M
Innodb_log_file_size = 100 M
Innodb_log_files_in_group = 4
Innodb_file_io_threads = 4
Innodb_thread_concurrency = 16
Innodb_max_dirty_pages_pct = 50
Transaction-isolation = READ-COMMITTED
Innodb_data_file_path = ibdata1: 10G; ibdata2: 5G: autoextend
Innodb_buffer_pool_instances = 4
Innodb_thread_concurrency = 32
### Server id ####
Log_bin_trust_function_creators = 1
Read_only = 0
Server_id = 5
8) create a database
[Plain]
Cd/opt/mysql
./Scripts/mysql_install_db -- user = mysql
According to my. the data file directory and log file directory set in cnf generate corresponding data files and log files, and create a system database (such as mysql, test, information_schema, cece_schema)
9) set the root password and create a read-only account
[Plain]
Export PATH = $ PATH:/opt/mysql/bin
Mysqladmin-u root password '***'
Mysql-uroot-p
Root @ (none) 06:08:34> grant all privileges on *. * TO 'root' @ '% 'identified BY' *** 'with grant option;
Root @ (none) 06:08:44> grant select on *. * TO 'rnd' @ '% 'identified '***';
10) Finally, add MySQL to the system startup item and start the system.
[Plain]
Cp./support-files/mysql. server/etc/rc. d/init. d/mysqld # Add Mysql to the system to start
Chmod 755/etc/init. d/mysqld # Add execution permission
Chkconfig mysqld on # add to startup
In this way, execute service mysqld start to start MySQL :).
BitsCN.com