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)
# 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
# groupadd mysql# useradd mysql
4) Create the MySQL software installation directory and data storage directory
Mkdir-p/opt/mysql # MySQL installation directory chown-R mysql: mysql/opt/mysqlmkdir-p/data/mysql # MySQL data storage directory mkdir-p/data/mysql/data # data mkdir-p/data/mysql/log # log storage mkdir-p/data/mysql/tmp # store the temporary file chown-R mysql: mysql/data/mysql
5) Compile and install MySQL using cmake
tar zxvf mysql-5.6.13.tar.gzcd mysql-5.6.13cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/opt/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1makemake 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
[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/mysqldatadir = /data/mysql/datatmpdir = /data/mysql/tmpsocket = /opt/mysql/run/mysql.sock#### Base configure info ####port = 3306skip-name-resolveold_passwords = 0lower_case_table_names = 1open_files_limit = 65535read_rnd_buffer_size = 5Mmax_allowed_packet = 24Mmax_connect_errors = 50000max_connections = 1000max_user_connections = 950 thread_cache_size=64table_open_cache=1024thread_stack=262144wait_timeout=864000#### Log info ####log-error = /data/mysql/log/alert.logslow_query_log=1slow_query_log_file= /data/mysql/log/slow.loglog-slow-admin-statementslong_query_time = 0.1slow_launch_time=1#### Binary log && Relay log ####binlog_format='MIXED'log-bin = /data/mysql/log/mysql-binlog-slave-updates = 1relay-log = /data/mysql/log/mysqld-relay-binrelay-log-index = /data/mysql/log/mysqld-relay-bin.indexmaster-info-file = /data/mysql/log/master.inforelay-log-info-file = /data/mysql/log/relay-log.infomax_binlog_size = 500Mmax_binlog_cache_size = 2G#### query cache ####query_cache_size = 100Mquery_cache_limit = 1Kquery_cache_min_res_unit = 1Kquery_cache_type=2#myisamconcurrent_insert = 2key_buffer_size = 100Msort_buffer_size = 100Kjoin_buffer_size = 100Kread_buffer_size = 1Mmyisam_sort_buffer_size = 100M#innodb plugin#innodbdefault-storage-engine = INNODBinnodb_flush_method = O_DIRECTinnodb_file_per_table = 1innodb_open_files=60000innodb_flush_log_at_trx_commit = 2innodb_lock_wait_timeout = 100innodb_additional_mem_pool_size = 20Minnodb_buffer_pool_size = 16Ginnodb_log_buffer_size= 400Minnodb_log_file_size = 100Minnodb_log_files_in_group = 4innodb_file_io_threads = 4innodb_thread_concurrency = 16innodb_max_dirty_pages_pct = 50transaction-isolation = READ-COMMITTEDinnodb_data_file_path = ibdata1:10G;ibdata2:5G:autoextendinnodb_buffer_pool_instances=4innodb_thread_concurrency=32 ### Server id #### log_bin_trust_function_creators=1 read_only=0 server_id=5
8) Create a database
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
export PATH=$PATH:/opt/mysql/bin mysqladmin -u root password '***'mysql -uroot -proot@(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 BY '***';
10) Finally, add MySQL to the system startup Item and start the system.
Cp. /support-files/mysql. server/etc/rc. d/init. d/mysqld # Add Mysql to the system and start chmod 755/etc/init. d/mysqld # Add execution permission chkconfig mysqld on # Add startup
In this way, execute service mysqld start to start MySQL :).