centos 7 源码安装mysql_centos7 源码安装mysql5.7.10

Mysql5.7版本更新后有很多变化,比如json等,连安装都有变化,他安装必须要BOOST库,不过mysql的官网源码有带boost库的源码和不带boost库的源码两种,因此有两种安装方式,其实都是一样的,仅仅是不带boost库源码的需要单独安装boost

5dd524bb6299

image.png

2、解压,cd到文件夹

tar -zxvf mysql-boost-5.7.10.tar.gz

cd mysql-5.7.10

3、安装依赖包:yum -y install gcc gcc-c++ ncurses ncurses-devel cmake

4、添加禁止登陆的mysql用户,这里是www用户

groupadd www

useradd -r -g mysql -s /bin/false www

5、编译安装

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=boost

make#注意这里花费时间很长,大约70分钟

make install

6、修改配置文件,前提先创建/data/mysql目录,并且为www所有,修改/etc/my.cnf配置文件为一下内容

[client]

port=3306

socket=/data/mysql/mysql.sock

[mysqld]

port=3306

user=www

datadir=/data/mysql/data

socket=/data/mysql/mysql.sock

basedir=/usr/local/mysql

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

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

slow_query_log=1

long_query_time=1

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

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# Settings user and group are ignored when systemd is used.

# If you need to run mysqld under a different user or group,

# customize your systemd unit file for mariadb according to the

# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]

#log-error=/var/log/mariadb/mariadb.log

#pid-file=/var/run/mariadb/mariadb.pid

#

# include all files from the config directory

#

!includedir /etc/my.cnf.d

7、配置启动文件cp support-files/mysql.server /etc/init.d/mysqld

8、初始化数据库(没有提示,就是成功)/usr/local/mysql/bin/mysqld --initialize --user=www

9、启动/etc/init.d/mysqld start

5dd524bb6299

image.png

10、MySQL从5.7开始不支持安装后使用空密码进行登录,因此在这里需要先查询程序生成的临时密码(就是第七步配置文件的日志文件路径):cat /data/mysql/mysql-error.log |grep 'A temporary password';也可以在配置文件my.cf增加skip-grant-tables重启mysql后可免密登录

5dd524bb6299

image.png

11、配置环境变量:vim /root/.bash_profile把PATH=$PATH:$HOME/bin修改为PATH=$PATH:$HOME/bin:/usr/local/mysql/bin,最后重新载入source /root/.bash_profile

12、连接mysqlmysql -uroot -p 然后输入刚刚第九步的密码,即可连接成功

5dd524bb6299

image.png

13、这时需要修改密码:alter user 'root'@'localhost' identified by 'your_password';

好了,mysql5.7.10就安装成功了

若是要设置开机启动:systemctl enable mysqld.service

前提先设置mysqld.service。传送门

5dd524bb6299

image.png

如果还有问题,不妨和我一起讨论。请多多关注:python基础

干货不定时更新喔

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值