mysql利用yum安装指定数据存放路径
测试环境:
Centos6.5、MySQL5.6.28
yum安装具有速度快,便捷关键是不用编译,编译时间太久了!
01、下载mysql
https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/ ###一般每个都下载下,在同版本下!
http://repo.mysql.com/
02、安装rpm文件
yum localinstall -y * ###把需要安装的rpm文件放到一个文件夹中
yum install -y mysql-server ###利用本地或yum源,自动下载安装
03、修改/etc/my.cnf
[client] default-character-set=utf8 ###设定客户端连接字符集 [mysql] auto-rehash ####自动补全命令 default-character-set=utf8 ####mysql连接字符集 [mysqld] innodb_buffer_pool_size = 128M join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M
#basedir=/home/data/mysql ###定义MySQL存放位置 datadir=/mysql/data ###设定数据存放位置 socket=/mysql/data/mysql.sock ###设定服务端字符集 init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake symbolic-links=0 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysqld_safe] log-error=/mysql/data/mysqld.log pid-file=/mysql/data/mysqld.pid ###建议跟数据存放路径
04、修改/etc/init.d/mysqld
[root@zabbix_proxy ~]# cat /etc/init.d/mysqld
#!/bin/sh
#
# mysqld This shell script takes care of starting and stopping
# the MySQL subsystem (mysqld).
#
# chkconfig: - 64 36
# description: MySQL database server.
# processname: mysqld
config=/etc/my.cnf ###指定配置文件,启动会优先找config的配置项
05、建立sock连接文件
ln -sf /mysql/data/mysql.sock /var/lib/mysql/mysql.sock
06、启动测试
service mysqld start
tail -f /mysql/data/mysqld.log ###查看日志很关键
关键点:
service mysqld start 启动的实质就是mysqld_safe启动,而mysqld ,只需指定config=/etc/my.cnf即可
/usr/bin/mysqld_safe --defaults-file=/etc/my.cnf &