您好,欢迎访问一九零五行业门户网

CentOS7上编译安装MySQL5.6.23_MySQL

1.下载源码
wget http://dev.mysql.com/get/downloads/mysql-5.6/mysql-5.6.23.tar.gz
2.解压
tar zxvf mysql-5.6.23.tar.gz
3.安装必要的包
sudo yum install cmake gcc-c++ ncurses-devel perl-data-dumper
4.进入mysql源码目录,生成makefile
cmake .
5.编译
make
6.安装
sudo make install
mysql将会安装到/usr/local/mysql路径。
7.添加mysql用户和组
sudo groupadd mysqlsudo useradd -r -g mysql mysql
8.修改目录和文件权限,安装默认数据库
cd /usr/local/mysqlsudo chown -r mysql .sudo chgrp -r mysql .sudo scripts/mysql_install_db --user=mysql
sudo chown -r root .
sudo chown -r mysql data
至此,mysql就可以启动运行了。
9.启动mysql
centos7自带mariadb的支持,/etc下默认存在my.cnf文件干扰mysql运行,需要先删掉
cd /etcsudo rm -fr my.cnf my.cnf.d
然后再/etc下重建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 = 10000sql_mode = no_engine_substitution,strict_trans_tables #binary log log-bin = mysql-binbinlog_format = mixedexpire_logs_day = 30#slow query log slow_query_log = 1slow_query_log_file = /var/log/mysql/slow.loglong_query_time = 3log-queries-not-using-indexeslog-slow-admin-statements
现在可以启动mysql了
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
centos7 不能使用service控制mysql服务,而源码安装的mysql也没有提供systemd的控制脚本。
于是编辑/etc/rc.d/rc.local文件,添加mysql的开机启动命令。
/usr/local/mysql/bin/mysqld_safe --user=mysql &
然后给/etc/rc.d/rc.local添加可执行权限
sudo chmod a+x /etc/rc.d/rc.local
9.修改root密码/usr/loca/mysql/bin/mysql -urootuse mysql;update user set password = password('test2015') where user = 'root';
grant all privileges on *.* to root@'%' identified by 'stcm2015';
flush privileges;
至此,安装基本完成了,一个mysql就能用了。
其它类似信息

推荐信息