1. 安装
- useradd mysql
- yum install gcc gcc-c++ autoconf automake ncurses ncurses-devel wget vim cmake
- wget
- tar zxvf mysql-5.5.28.tar.gz
- cd $(echo mysql-5.5.28.tar.gz |awk '{gsub(".tar.gz","")}{print}')
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/data/mysql/data -DMYSQL_UNIX_ADDR=/data/mysql/data//mysql.sock
-DWITH_INNOBASE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=3306
-DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-DMYSQL_UNIX_ADDR=/data/mysql/data/mysql.sock -DMYSQL_USER=mysql
-DWITH_DEBUG=0
make;make install
export PATH=$PATH:/usr/local/mysql/bin
echo export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile
source /etc/profile
/usr/local/mysql/scripts/mysql_install_db --user=mysql
--basedir=/usr/local/mysql/ --datadir=/data/mysql/data
2. my.cnf
- #MYSQL 5.5
-
- [client]
-
- port = 3306
- socket = /data/mysql/data/mysql.sock
- character-sets-dir=utf8
-
- [mysqld]
-
- server-id = 1
- user = mysql
- port = 3306
- socket = /data/mysql/data/mysql.sock
- basedir = /usr/local/mysql
- datadir = /data/mysql/data
- character-set-server=utf8
- pid-file = /data/mysql/mysql.pid
- default-storage-engine=INNODB
- #lower_case_table_names=1 #查询表不区分大小写
-
- log-error = /data/mysql/data/mysql.log
- open_files_limit = 10240
- back_log = 600
- max_connections = 8000
- max_connect_errors = 6000
- table_cache = 1024
- external-locking = FALSE
- max_allowed_packet = 32M
- sort_buffer_size = 1M
- join_buffer_size = 1M
- thread_cache_size = 300
- thread_concurrency = 8
- query_cache_size = 512M
- query_cache_limit = 2M
- query_cache_min_res_unit = 2k
- thread_stack = 192K
- transaction_isolation = READ-COMMITTED
- tmp_table_size = 512M
- max_heap_table_size = 512M
- long_query_time = 3
- #log-slave-updates
-
- log-bin = /data/mysql/binlog
- binlog_cache_size = 4M
- binlog_format = MIXED
- max_binlog_cache_size = 8M
- max_binlog_size = 1G
- relay-log-index = /data/mysql/relaylog
- relay-log-info-file = /data/mysql/relaylog
- relay-log = /data/mysql/relaylog
- key_buffer_size = 256M
- read_buffer_size = 1M
- read_rnd_buffer_size = 16M
- bulk_insert_buffer_size = 64M
- myisam_sort_buffer_size = 128M
- myisam_max_sort_file_size = 10G
- myisam_repair_threads = 1
- myisam_recover
-
- # *** Replication related settings
- #server-id = 111
- #master-host = 192.168.1.252
- #master-user = repl
- #master-password = slave
- #master-port = 3310
- #skip-slave-start = 1
- #replicate-ignore-db = information_schema,mysql,m4n,m4n_group,vgift,m4n_backup
- #replicate-do-db = m4n
- #replicate-do-db = m4n_group
- #replicate-do-db = vgift
- #replicate-do-db = m4n_backup
- #replicate-do-db = db
- #replicate-wild-ignore-table=
- #read_only
- #interactive_timeout = 120
- wait_timeout = 120
- expire_logs_days = 7
-
-
-
-
- #skip-name-resolve
- #master-connect-retry = 10
- #slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
- innodb_additional_mem_pool_size = 16M
- #innodb_buffer_pool_size = 4G
- innodb_buffer_pool_size = 512M
- #innodb_data_file_path = ibdata1:2G:autoextend
- innodb_data_file_path = ibdata1:256M:autoextend
- innodb_file_io_threads = 4
- innodb_thread_concurrency = 8
- innodb_flush_log_at_trx_commit = 2
- innodb_log_buffer_size = 16M
- innodb_log_file_size = 128M
- innodb_log_files_in_group = 3
- innodb_max_dirty_pages_pct = 90
- innodb_lock_wait_timeout = 120
- innodb_file_per_table = 0
- #log-slow-queries = /data0/mysql/3306/slow.log
- ##long_query_time = 10
-
- [mysqldump]
- quick
- max_allowed_packet = 128M
- default-character-set=utf8
-
- [mysql]
- no-auto-rehash
- prompt=mysql [\\d]>\\_
- max_allowed_packet = 512M
- default-character-set=utf8
3.启动
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
/usr/local/mysql/bin/mysqld_safe --user=mysql &
阅读(2063) | 评论(0) | 转发(0) |