Environment Introduction
System: CentOS 5.8 64-bit
MySQL version: mysql-5.6.22-linux-glibc2.5-x86_64
Note: Install in binary. Because MySQL compilation takes a long time.
Installation steps
1. Preparatory work for the installation.
A. Turn off SELinux
Vim/etc/sysconfig/selinux
Selinux=disabled
B. Temporary closure
Setenforce 0
C. Turn off the firewall
Service Iptables Stop
Either method A and method B are selected, but method a needs to restart the server to take effect.
2. Download the required MySQL binary package, download the installation package I put in the/opt/software directory
3. Unzip the installation package
A.mkdir/opt/mysql
B.cd/opt/mysql
C.tar-zxf/opt/software/mysql-5.6.22-linux-glibc2.5-x86_64.tar.gz
D.cd/usr/local
E.ln-s/opt/mysql/mysql-5.6.22-linux-glibc2.5-x86_64 MySQL
4. Create user groups and users
A.groupadd MySQL
B.useradd-g mysql-d/data/mysql/mysql_3306-s/sbin/nologin MySQL
5. Create a configuration file
A.cp/usr/local/mysql/support-files/my-default.cnf/etc/my.cnf
6. Initializing the database
A.mkdir-p/data/mysql/mysql_3306
B.chown-r Mysql:mysql/data/mysql/chown-r mysql:mysql/usr/local/mysql/
C.cd/usr/local/mysql
E../script/mysql_install_db-user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql/mysql_3306
7. Add Environment variables
A.echo "path= $PATH:/usr/local/mysql/bin" >>/etc/profile
B.source/etc/profile
8. Start
A.cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld
B./etc/init.d/mysqld start
Error occurred during installation:
1. At the start times wrong:
Check the MySQL error log at this time such as:
The solution to this problem is:
A. Deleting all files in the/data/mysql/mysql_3306 directory
B. Initializing the database again
./mysql_install_db-user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql/mysql_3306--ldata=/data/mysql/ Mysql_3306/data
Of course there is another way to initialize the data./mysql_install_db-user=mysql--defautls-file=/etc/my.cnf. Finally, it is important to remember that initializing the database must be done under Basedir.
I am currently in the installation of such a problem, if there are other problems can be a message to communicate, the bottom is my configuration file.
[[email protected] support-files]# cat/etc/my.cnf #my. cnf[client]port = 3306socket =/tmp/mysql. sock[mysql]prompt= "\\[email protected]\\h:\p \\r:\\m:\\s [\\d]>" #tee =/data/mysql/mysql_3306/data/ Query.logno-auto-rehash[mysqld_multi]mysqld =/usr/local/mysql/bin/mysqld_safemysqladmin =/usr/local/mysql/bin/ Mysqladminlog =/opt/mysql/mysqld_multi.log[mysqld] #miscuser = Mysqlbasedir =/usr/local/mysqldatadir =/data/mysql/ Mysql_3306/dataport = 3306socket =/tmp/mysql.sockevent_scheduler = 0#timeoutinteractive_timeout = 300wait_timeout = 300 #character setcharacter-set-server = Utf8open_files_limit = 65535max_connections = 100max_connect_errors = 100000skip-name-resolve = 1#logslog-output=fileslow_query_log = 1slow_query_log_file = Slow.loglog-error = error.loglog_warnings = 2pid-file = Mysql.pidlong_query_time = 1#log-slow-admin-statements = # log-queries-not-using-indexes = 1log-slow-slave-statements = 1#binlogbinlog_format = Mixedserver-id = 203306log-bin = Mybinlogbinlog_cache_size = 4mmax_binlog_size = 1gmax_binlog_cache_size = 2gsync_binlog = 0expire_logs_days = 10#relay Logskip_slave_start = 1max_relay_log_size = 1grelay_log_purge = 1relay_log_recovery = 1log_slave_updates# Slave-skip-errors=1032,1053,1062explicit_defaults_for_timestamp=1#buffers & cachetable_open_cache = 2048table_ Definition_cache = 2048table_open_cache = 2048max_heap_table_size = 96msort_buffer_size = 2Mjoin_buffer_size = 2Mthread_ Cache_size = 256query_cache_size = 0query_cache_type = 0query_cache_limit = 256kquery_cache_min_res_unit = 512thread_ stack = 192ktmp_table_size = 96mkey_buffer_size = 8mread_buffer_size = 2mread_rnd_buffer_size = 16Mbulk_insert_buffer_ Size = 32m#myisammyisam_sort_buffer_size = 128mmyisam_max_sort_file_size = 10gmyisam_repair_threads = 1#innodbinnodb_ Buffer_pool_size = 100minnodb_buffer_pool_instances = 1innodb_data_file_path = Ibdata1:1g:autoextendinnodb_flush_log _at_trx_commit = 2innodb_log_buffer_size = 64minnodb_log_file_size = 500minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 50innodb_file_per_table = 1innodb_rollback_on_ Timeoutinnodb_status_file = 1innodb_io_capacity = 2000transaction_isolation = Read-committedinnodb_flush_method = O_ Instance special configuration for direct# port number 3306 [Mysqld3306]port =3306 server-id=203306# Specify Basedir and datadirbasedir=/usr/local/for the corresponding version of this instance Mysqldatadir =/data/mysql/mysql_3306/datasocket =/tmp/mysql_3306.sock# Reconfigure these options, not as with the global configuration, directly overriding the global settings above INNODB_BUF Fer_pool_size = 100m#transaction_isolation = repeatable-read[mysqld3308]port=3308server-id=203308#binlog-do-db= db01basedir=/usr/local/mysqldatadir =/data/mysql/mysql_3308/datasocket =/tmp/mysql_3308.sock# Reconfigure these several options, not with the global configuration One The global settings innodb_buffer_pool_size = 100minnodb_flush_log_at_trx_commit = 2sync_binlog = 0[mysqld3309]port= 3309server-id=203309#binlog-do-db=db01basedir=/usr/local/mysqldatadir =/data/mysql/mysql_3309/datasocket =/tmp /mysql_3309.sock# reconfigure these options, not the same as the global configuration, will directly overwrite the above global settings innodb_buffer_pool_size = 100minnodb_flush_log_at_trx_commit = 2sync_binlog = 0
MySQL Installation Chapter