os:centos6.5

mysql:5.6.29

选择版本

前往官方网站:http://dev.mysql.com/downloads/mysql/5.6.html#downloads
选择一个适合的稳定版本,比如5.6.29

安装相关支持库

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel ssse2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gettext-devel libXpm-devel libtool cmake

安装mysql

[root@dbtest opt]# groupadd mysql
[root@dbtest opt]# useradd -g mysql mysql
[root@dbtest opt]# tar -zxvf mysql-5.6.29.tar.gz 
[root@dbtest opt]# cd mysql-5.6.29 
[root@dbtest mysql-5.6.29]# cmake .
[root@dbtest mysql-5.6.29]# make && make install

配置etc/hosts,建议127.0.0.1到dbtest的映射,否则会报错误[TIPS]安装数据库提示无法解析机器名处理

[root@dbtest mysql-5.6.29]#vi /etc/hosts

创建配置文件my.cnf

[root@dbtest mysql-5.5.36]#cp support-files/my-medium.cnf /etc/my.cnf
vim /etc/my.cnf #需要加入basedir,和datadir否则会出问题
[mysqld]
basedir =/usr/local/mysql
datadir =/usr/local/mysql/data

配置

[root@dbtest mysql-5.6.29]#cd /usr/local/mysql/
[root@dbtest mysql-5.6.29]#chown -R mysql .
[root@dbtest mysql-5.6.29]#chgrp -R root .
[root@dbtest mysql-5.6.29]#scripts/mysql_install_db --user=mysql

设置密码

[root@dbtest mysql-5.6.29]#./bin/mysqld_safe --user=mysql &
[root@dbtest mysql-5.6.29]#./bin//mysqladmin -u root password 111111

创建自启动服务

[root@dbtest mysql-5.6.29]#cp support-files/mysql.server /etc/init.d/mysqld
[root@dbtest mysql-5.6.29]#chmod +x /etc/init.d/mysqld
[root@dbtest mysql-5.6.29]#chkconfig mysqld on

服务启停

[root@dbtest mysql-5.6.29]#service mysqld start
[root@dbtest mysql-5.6.29]#service mysqld stop

附my.cnf

[client]
port		= 3306
socket		= /tmp/mysql.sock


[mysqld]
port		= 3306
socket		= /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 10M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
max_connections=500


log-bin=mysql-bin

binlog_format=mixed

server-id	= 1


default-storage-engine = InnoDB
character-set-server=utf8
skip-name-resolve
[mysqldump]
quick
max_allowed_packet = 16M

[mysqld]
basedir =/usr/local/mysql
datadir =/usr/local/mysql/data
skip-name-resolve

[mysql]
no-auto-rehash
default-character-set=utf8
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout