一、安装插件
1.apt-get install cmake
2.apt-get install bison
3.apt-get install libncurses5-dev
4.apt-get install gcc g
二、下载安装包
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.18.tar.gz
tar zxvf mysql-boost-5.7.18.tar.gz
三、创建mysql用户组
groupadd mysql
useradd -g mysql mysql
四、编译安装mysql
代码语言:javascript复制cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/usr/local/mysql/data
-DWITH_BOOST=./boost/boost_1_59_0
-DSYSCONFDIR=/etc
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_MEMORY_STORAGE_ENGINE=1
-DENABLED_LOCAL_INFILE=1
-DWITH_READLINE=1
-DMYSQL_TCP_PORT=3306
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
make
make install
五、配置mysql
1.设置mysql用户权限
chown -R mysql /usr/local/mysql
chgrp -R mysql /usr/local/mysql
2.修改配置文件
官网从5.7.18不在二进制包中提供my-default.cnf文件,如果有需要添加的话,找到my.cnf文件所在位置,新建my.cnf文件添加配置即可
找到my.cnf应该所在位置:mysql --help | grep my.cnf
vim /etc/my.conf,临时添加如下配置:
代码语言:javascript复制[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
[mysqld]
user = mysql
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
2.初始化数据库
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
记住这个密码,更改root密码时使用
3.启动mysql
/usr/local/mysql/support-files/mysql.server start
4.设置mysql root密码
mysql -h 127.0.0.1 -u root -p
上面截图里初始化时的密码:<c6dqzE<;0;w