c 5.6 mysql 配置文件_MySQL 5.6.13 编译安装配置详解

安装依赖:

yum -y install wget gcc-c++ cmake make bison ncurses-devel perl unzip

添加MySQL系统用户

useradd -M -s /sbin/nologin mysql

提前建立好相关目录

mkdir /data/mysql

下载MySQL源代码

wget http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.13.tar.gz

安装cmake

tar xzf cmake-2.8.11.2.tar.gz

cd cmake-2.8.11.2

./configure

make && make install

cd ..

安装MySQL

tar zxf mysql-5.6.13.tar.gz

cd mysql-5.6.13

cmake . -DCMAKE_INSTALL_PREFIX=$db_install_dir \

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

-DMYSQL_DATADIR=$db_data_dir \

-DSYSCONFDIR=/etc \

-DMYSQL_USER=mysql \

-DMYSQL_TCP_PORT=3306 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DENABLED_LOCAL_INFILE=1 \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DEXTRA_CHARSETS=all \

-DWITH_BIG_TABLES=1 \

-DWITH_DEBUG=0

make && make install

cmake编译参数参考:http://www.linuxeye.com/Linux/MySQL-cmake-options.html

配置开机自启动:

/bin/cp support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig --add mysqld #CentOS

chkconfig mysqld on

update-rc.d mysqld defaults #Ubuntu

MySQL配置文件/etc/my.cnf

[mysqld]

basedir = /usr/local/mysql

datadir = /data/mysql

pid-file = /data/mysql/mysql.pid

character-set-server = utf8

collation-server = utf8_general_ci

user = mysql

port = 3306

default_storage_engine = InnoDB

innodb_file_per_table = 1

server_id = 1

log_bin = mysql-bin

binlog_format = mixed

expire_logs_days = 7

bind-address = 0.0.0.0

# name-resolve

skip-name-resolve

skip-host-cache

#lower_case_table_names = 1

ft_min_word_len = 1

query_cache_size = 64M

query_cache_type = 1

skip-external-locking

key_buffer_size = 16M

max_allowed_packet = 1M

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

# LOG

log_error = /data/mysql/mysql-error.log

long_query_time = 1

slow_query_log

slow_query_log_file = /data/mysql/mysql-slow.log

# Oher

#max_connections = 1000

open_files_limit = 65535

[client]

port = 3306

初始化数据库

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

chown mysql.mysql -R /data/mysql

添加环境变量

echo "export PATH=\$PATH:/usr/local/mysql/bin" >> /etc/profile

source /etc/profile

安全设置(设定初始密码,移除匿名用户,移除测试数据库):

方式一(执行脚本):

/usr/local/mysql/bin/mysql_secure_installation

方式二(手工删除):

/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"dbrootpwd\" with grant option;"

/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"dbrootpwd\" with grant option;"

/usr/local/mysql/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.user where Password='';"

/usr/local/mysql/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where User='';"

/usr/local/mysql/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"

/usr/local/mysql/bin/mysql -uroot -p$dbrootpwd -e "reset master;"

启动MySQL

service mysqld start

如果报错请查看日志/data/mysql/mysql-error.log

参考:lnmp中Install_MySQL函数部分

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值