#前世今生, http://my.oschina.net/yangchunlian/blog/714076
在上篇文章中,我使用的是编译安装,我也知道编译安装是最好的。
但是有时,make好慢,耽误使用。。
有没有更快的方式啊,在这里介绍一种比较快的方式,那就是直接用tar包安装。
步骤如下:
环境:CentOS release 6.6 (Final) X64
#1—下载MysqL安装包
打开 http://downloads.mysql.com/archives/community/
选择合适的版本,我这儿选择 5.6.26
选择 linux - Generic
linux 上,请 wget http://downloads.mysql.com/archives/get/file/mysql-5.6.26-linux-glibc2.5-i686.tar.gz 或者 拷贝现有的安装包
#2—安装 ##2.0—新建目录 (我这儿准备MysqL的安装目录是/home/quant_group/MysqL/3306) mkdir -p /home/quant_group/MysqL cd /home/quant_group/MysqL wget http://downloads.mysql.com/archives/get/file/mysql-5.6.26-linux-glibc2.5-i686.tar.gz 或者别的方式将压缩包传过来 ##2.1— 解压 tar zxvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.26-linux-glibc2.5-x86_64 3306 ##2.2— 新建MysqL安装目录
mkdir -p /home/quant_group/MysqL/3306 mkdir -p /home/quant_group/MysqL/3306/log mkdir -p /home/quant_group/MysqL/3306/tmp ##2.3— install useradd -M -s /sbin/nologin MysqL #添加MysqL用户 chown -R MysqL:MysqL /home/quant_group/MysqL/3306/ cd 3306/ ./scripts/MysqL_install_db --user=MysqL rm -f my.cnf scp 你自己写好的my.cnf chown -R MysqL:MysqL /home/quant_group/MysqL/3306/ ./bin/MysqLd_save &
此时已启动,可以查看ps -ef | grep MysqL 这种方式有个守护进程,当误操作kill了MysqLl时 会自动重启
##2.4— 登录MysqL及改密码与配置远程访问
MysqLadmin -u root password 'your_password' #修改root用户密码 MysqL -u root -p #登录MysqL,需要输入密码 MysqL>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION; #允许root用户远程访问 MysqL>FLUSH PRIVILEGES; #刷新权限 MysqL>exit
#3— 忘记密码怎么办? ##3.1— 关掉数据库 kill -9 进程号(注意有两个,按顺序kill掉) ##3.2— 启动数据库 cd $MysqL_HOME ./bin/MysqLd_safe --basedir=/home/quant_group/MysqL/3306/ --datadir=/home/quant_group/MysqL/3306/data --skip-grant-tables & ##3.3— 登录 MysqL -u root MysqL ##3.4— 改密 UPDATE user SET password=PASSWORD("new_password") WHERE user='root'; FLUSH PRIVILEGES;
自己的my.cnf配置
[MysqLd]
basedir = /home/quant_group/MysqL/3306
datadir = /home/quant_group/MysqL/3306/data
tmpdir = /home/quant_group/MysqL/3306/tmp
pid-file = /home/quant_group/MysqL/3306/data/my.pid
port = 3306
default_storage_engine = InnoDB
innodb_autoinc_lock_mode = 2
explicit_defaults_for_timestamp = true
#character-set-client-handshake = FALSE
character_set_server = utf8
skip-name-resolve
max_connect_errors = 100
max_allowed_packet = 20M
#
connect_timeout = 3600
wait_timeout = 86400
interactive_timeout = 86400
innodb_lock_wait_timeout = 10
#
log-error = /home/quant_group/MysqL/3306/log/error.log
#
slow_query_log = on
slow_query_log_file=/home/quant_group/MysqL/3306/log/slow-query.log
#slow_query_log_file = /home/quant_group/MysqL/3306/log/slow-query-log.log
long_query_time = 2
#log-queries-not-using-indexes
#log-slow-admin-statements
#log-slow-slave-statements
server-id = 155
log-bin = MysqL-bin
binlog-format = ROW
#
#20150731 Add
binlog-ignore-db=MysqL
replicate-ignore-db=MysqL
log-slave-updates=1
sync_binlog=1
innodb_flush_log_at_trx_commit=1
innodb_buffer_pool_size=5112M
innodb_log_buffer_size=2M
key_buffer_size=256M
tmp_table_size=64M
max_connections=500
thread_cache_size=120
#
auto_increment_offset=1
auto_increment_increment=2
###donation: 如有捐赠意向的朋友,请捐赠到支付宝账号:qdcccc@gmail.com 账户名:杨春炼
###ask for help: 如需帮助,请加QQ:1028750558或微信:lian-ye