介绍下在centos6的64位系统下,安装与配置mysql5.6.x的方法。
首先,yum安装需要的包:
第二步:关闭itables和SElinux,
第三步:准备安装目录等工作
第四步:解压源码包并编译
# tar -zxv -f mysql-5.6.10.tar.gz
# cd mysql-5.6.10
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DDEFAULT_CHARSET=gbk
-DDEFAULT_COLLATION=gbk_chinese_ci
-DEXTRA_CHARSETS=all
-DWITH_myisam_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DMYSQL_DATADIR=/usr/local/mysql/data
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
-DSYSCONFDIR=/etc
-DWITH_SSL=yes
-DENABLE_DOWNLOADS=1
# make & make install
编译注解:
编译过程中可能会报一个gmock错误,去mysql解压目录下的source_downloads下,用unzip解压gmock的zip包,然后回到mysql解压根目录继续执行cmake编译命令,问题即可解决。
第五步:编辑my.cnf文件,vim /etc/my.cnf
[mysql]
# CLIENT #
port = 3306
socket = /tmp/mysql.sock
[mysqld]
# GENERAL #
user = mysql
default_storage_engine = InnoDB
socket = /tmp/mysql.sock
pid_file = /var/run/mysqld/mysqld.pid
# MyISAM #
key_buffer_size = 32M
myisam_recover = FORCE,BACKUP
# SAFETY #
max_allowed_packet = 16M
max_connect_errors = 1000000
skip_name_resolve
sql_mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,
NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
sysdate_is_now = 1
innodb = FORCE
innodb_strict_mode = 1
# DATA STORAGE #
datadir = /usr/local/mysql/data
# BINARY LOGGING #
log-bin =/usr/local/mysql/log/bin.log
expire_logs_days = 30
sync_binlog = 1
# CACHES AND LIMITS #
key_buffer = 256M
max_allowed_packet = 32M
sort_buffer_size = 16M
read_buffer_size = 4M
read_rnd_buffer_size = 16M
thread_stack = 8M
tmp_table_size = 32M
max_heap_table_size = 32M
query_cache_type = 1
query_cache_size = 128M
query_cache_limit = 2M
max_connections = 2048
thread_cache_size = 512
open_files_limit = 65535
table_definition_cache = 1024
table_open_cache = 2048
# INNODB #
innodb_log_files_in_group = 2
innodb_log_file_size = 64M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
# 2G这个值配置低的话建议改小即可
innodb_buffer_pool_size = 2G
# LOGGING #
log-error=/usr/local/mysql/log/error.log
general_log=1
general_log_file=/usr/local/mysql/log/mysql.log
slow_query_log=1
slow_query_log_file=/usr/local/mysql/log/slowquery.log
log-output=FILE
# 避免MySQL的外部锁定,减少出错几率增强稳定性 #
skip-external-locking
# 禁止sql读取本地文件 #
local-infile=0
说明:
因为使用的是阿里云69元的服务器。# CACHES AND LIMITS #这块配置需要注释掉,不然无法启动mysql,并报pid文件错误,innodb_buffer_pool_size这个改成了只有16M了。
第六步:
将mysql的库文件路径加入系统的库文件搜索路径中
方法一:直接做软链接
方法二:利用ldconfig导入系统库
输出mysql的头文件到系统头文件
进入安装路径,初始化配置脚本
复制mysql启动脚本到系统服务目录
系统启动项相关配置
启动mysql
注:编译时若socket路径自定义为/var/lib/mysql/mysql.sock,这里需要创建一个mysql接口的软链接,防止登陆后台或安装论坛报错.
设置初始账户,并登陆后台:
到这里,就完成了在centos6中安装与配置mysql5.6.x,希望对大家有一定的帮助。