1.下载源码
# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.29.tar.gz
2.解压
# tar zxvf mysql-5.6.29.tar.gz
3.安装必要的包
# yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake
4.进入mysql源码目录,生成makefile
# cmake .
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
5.编译
# make
6.安装
# make install
清理
# make clean
mysql将会安装到/usr/local/mysql路径。
7.添加mysql用户和组
# groupadd mysql
# useradd -r -g mysql mysql
8.修改目录和文件权限,安装默认数据库
# cd /usr/local/mysql
# chown -R mysql .
# chgrp -R mysql .
# scripts/mysql_install_db –user=mysql
# chown -R root .
# chown -R mysql data
至此,mysql就可以启动运行了。
9.启动mysql
CentOS7自带MariaDB的支持,/etc下默认存在my.cnf文件干扰mysql运行,需要先删掉
cd /etc
rm -rf my.cnf my.cnf.d
然后再/etc下重建my.cnf文件,内容如下(或可以不创建,但已经要将/etc/my.cnf删除,默认使用:/usr/local/mysql/my.cnf)
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = …..
# datadir = /data/mysql/data
# port = …..
# server_id = …..
# socket = …..
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
max_connection = 10000
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES (责任编辑:最模板) |