mysql libs 5.6.23_CentOS 7 上编译安装MySQL 5.6.23

CentOS7自带MariaDB,将其删掉

rpm -qa | grep mariadb

rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64

rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64

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 mysql

sudo useradd -r -g mysql mysql

8.修改目录和文件权限,安装默认数据库

cd /usr/local/mysql

sudo 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

在/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 = 10000

sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

#binary log

log-bin = mysql-bin

binlog_format = mixed

expire_logs_day = 30

#slow query log

slow_query_log = 1

slow_query_log_file = /var/log/mysql/slow.log

long_query_time = 3

log-queries-not-using-indexes

log-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 -uroot

use mysql;

UPDATE user SET password = PASSWORD('test2015') WHERE user = 'root';

GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'passwd2015';

FLUSH PRIVILEGES;

至此,安装基本完成了,一个mysql就能用了。

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值