Mysql5.7版本更新后有很多变化,比如json等,连安装都有变化,他安装必须要BOOST库,不过mysql的官网源码有带boost库的源码和不带boost库的源码两种,因此有两种安装方式,其实都是一样的,仅仅是不带boost库源码的需要单独安装boost
1、先下载源码:https://downloads.mysql.com/archives/community/
这里下载的是带boost
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
10、MySQL从5.7开始不支持安装后使用空密码进行登录,因此在这里需要先查询程序生成的临时密码(就是第七步配置文件的日志文件路径):cat /data/mysql/mysql-error.log |grep 'A temporary password'
;也可以在配置文件my.cf增加skip-grant-tables
重启mysql后可免密登录
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
然后输入刚刚第九步的密码,即可连接成功
13、这时需要修改密码:alter user 'root'@'localhost' identified by 'your_password';
好了,mysql5.7.10就安装成功了
若是要设置开机启动:systemctl enable mysqld.service
前提先设置mysqld.service。传送门
网友评论