centos下cmake编译安装mysql5.7.24

一、centos6.5推荐最小安装。自定义添加如图两个包

centos下cmake编译安装mysql5.7.24

centos下cmake编译安装mysql5.7.24

二、安装cmake3.0(mysql5.7要求cmake2.9以上。cmake3.1要求gcc g++4.8以上。所以选自3.0)

1、分别执行 ./configure  gmake  gmake install

三、安装依赖包

1、yum install ncurses-devel -y

yum install bison-devel -y

四、创建用户和用户组

 1、groupadd mysql

useradd mysql -s /sbin/nologin -M -g mysql

chown -R mysql:mysql /usr/local/mysql

chown -R mysql:mysql /data/3306

2、创建boost库

mkdir -p /usr/local/boost

下载boost_1_59_0。并解压到该目录

3、

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/3306/data \
-DMYSQL_UNIX_ADDR=/data/3306/mysql.sock \
-DEXTRA_CHARSETS=all \
-DSYSCONFDIR=/data/3306 \        配置文件my.cnf路径
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_BOOST=/usr/local/boost \
-DWITH_DEBUG=0

4、make && make install

5、实例初始化

cd /usr/local/mysql

./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/3306/data/

6、添加环境变量

echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

source /etc/profile

7、配置数据库

(1)复制启动文件

cp support-files/mysql.server /etc/init.d/mysqld

chmod 755 /etc/init.d/mysqld

cp bin/my_print_defaults /usr/bin/

(2)修改启动脚本  vi /etc/init.d/mysqld

centos下cmake编译安装mysql5.7.24

(3)修改mysql的配置文件  vi /etc/my.cnf

[mysqld]
basedir = /usr/local/mysql
datadir = /data/3306/data/
socket = /data/3306/mysql.sock
user = mysql
tmpdir = /data/3306/
symbolic-links=0

[mysqld_safe]

log-error = /data/3306/data/error.log
pid-file = /data/3306/data/mysql.pid

8、启动数据库

service mysqld start(密码是数据库初始化的时候随机生成的)

9、安装后的配置

登陆客户端执行命令总报错 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

(1) SET PASSWORD = PASSWORD("new password");

(2)ALTER USER ‘root’@‘localhost’ PASSWORD EXPIRE NEVER;

(3)flush privileges;  刷新权限,如此重新登陆即可正常使用

上一篇:CentOS7编译安装MySQL5.7.24


下一篇:自定义UICollectionViewLayout并添加UIDynamic - scorpiozj(转)