您的位置:首页 > 数据库 > MySQL

mysql 5.6安装与配置

2015-07-30 15:57 531 查看
采用yum安装依赖包

[root@MYSQLDB ~]# yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* cmake bison

创建mysql用户与用户组

[root@MYSQLDB ~]# groupadd mysql

[root@MYSQLDB ~]# useradd -r -g mysql mysql

安装mysql

[root@MYSQLDB ~]# tar zxvf mysql-5.6.19.tar.gz

[root@MYSQLDB ~]# cd mysql-5.6.19

[root@MYSQLDB mysql-5.6.19]# cmake ./ -DCMAKE_INSTALL_PREFIX=/opt/mysql/ -DMYSQL_DATADIR=/opt/mysql/data -DMYSQL_UNIX_ADDR=/opt/mysql/data/mysqld.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=/opt/mysql/data/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0

[root@MYSQLDB mysql-5.6.19]#make && make install

赋予相关权限

[root@MYSQLDB mysql-5.6.19]# chown -R mysql:mysql /opt/mysql

[root@MYSQLDB mysql-5.6.19]# /opt/mysql/scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data

mysql配置文件

[root@MYSQLDB mysql-5.6.19]# cp support-files/my-default.cnf /etc/my.cnf

[root@MYSQLDB mysql-5.6.19]# cp support-files/mysql.server /etc/init.d/mysql

[root@MYSQLDB mysql-5.6.19]# chmod +x /etc/init.d/mysql

[root@MYSQLDB mysql-5.6.19]#mkdir /opt/mysql/logs

[root@MYSQLDB mysql-5.6.19]#chown -R mysql:mysql /opt/mysql/logs

[root@MYSQLDB mysql-5.6.19]# chkconfig mysql on

配置/etc/my.cnf

[root@MYSQLDB etc]# vi my.cnf

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[client]

port
= 3306

socket
= /opt/mysql/data/mysql.sock

default-character-set = utf8

################Basic############

[mysqld]

server-id
= 1

port
= 3306

socket
= /opt/mysql/data/mysql.sock

skip-external-locking

skip-name-resolve

default-storage-engine=INNODB

character-set-server=utf8

wait_timeout=500

connect_timeout=20

interactive_timeout=500

back_log=500

event_scheduler=ON

##########binlog##########

expire-logs-days=5

log-bin=mysql-bin

binlog_format = ROW

log_slave_updates

max_binlog_size=128M

binlog_cache_size=2M

sync_binlog=1

#################slow log ###########

slow-query_log=1

slow-query_log_file=/opt/mysql/logs/mysql.slow

long_query_time=2

####################error log####

log_error=/opt/mysql/logs/error.log

#################per_thread_buffers#############

max_connections=1024

max_user_connections=2000

max_connect_errors=10000

key_buffer_size=64M

max_allowed_packet=128M

table_open_cache=6144

table_definition_cache=4096

sort_buffer_size=512k

read_buffer_size=512k

read_rnd_buffer_size=512k

join_buffer_size=512k

tmp_table_size=64M

max_heap_table_size=64M

query_cache_type=0

query_cache_size=0

bulk_insert_buffer_size=32M

thread_cache_size=64

thread_concurrency=32

thread_stack=256K

################INNODB################

innodb_data_home_dir = /opt/mysql/data

innodb_log_group_home_dir = /opt/mysql/data

innodb_data_file_path = ibdata1:10M:autoextend

innodb_buffer_pool_size=3G

innodb_flush_log_at_trx_commit=1

innodb_lock_wait_timeout=10

innodb_file_per_table

innodb_log_files_in_group=3

innodb_support_xa=1

innodb_sync_spin_loops=40

innodb_max_dirty_pages_pct=90

innodb_additional_mem_pool_size=16M

innodb_log_buffer_size=64M

innodb_flush_method=O_DIRECT

innodb_file_format=Barracuda

innodb_io_capacity=2000

log_bin_trust_function_creators=1

innodb_purge_threads=1

innodb_purge_batch_size=32

innodb_old_blocks_pct=75

transaction_isolation=READ-COMMITTED

innodb_read_io_threads=8

innodb_write_io_threads=8

[mysqldump]

quick

max_allowed_packet=128M

myisam_max_sort_sort_file_size=2G

[mysql]

no-auto-rehash

[myisamchk]

key_buffer_size = 64M

sort_buffer_size =256K

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

启动 mysql

/etc/init.d/mysql start

设置mysql初始密码,123456是密码,你可以设置自己需要的密码

[root@MYSQLDB mysql-5.6.19]# /opt/mysql/bin/mysqladmin -u root password '123456'

[root@MYSQLDB mysql-5.6.19]# ln -s /opt/mysql/bin/* /usr/bin/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: