mysql 编译源码_mysql-5.7.23源码编译安装

mysql-5.7.23源码编译安装

1.下载源码

# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.23.tar.gz

# tar xf mysql-5.7.23.tar.gz

2.隐藏版本信息

隐藏版本信息是XX电信运营商提出的变态要求,经测试版本信息不能直接删除,否则编译出错,暂时修改为100.100.100

# cd mysql-5.7.23

# vim VERSION

MYSQL_VERSION_MAJOR=100

MYSQL_VERSION_MINOR=100

MYSQL_VERSION_PATCH=100

MYSQL_VERSION_EXTRA=

版本高于5.8版本报错

#error "show_compatibility_56 is to be removed in MySQL 5.8"

解决办法:

修改sql/mysqld.cc源代码,将下面的内容(346-352行)

#if MYSQL_VERSION_ID >= 50800

#error "show_compatibility_56 is to be removed in MySQL 5.8"

#else

/*

Default value TRUE for the EMBEDDED_LIBRARY,

default value from Sys_show_compatibility_56 otherwise.

*/

my_bool show_compatibility_56= TRUE;

#endif /* MYSQL_VERSION_ID >= 50800 */

修改为

//#if MYSQL_VERSION_ID >= 50800

//#error "show_compatibility_56 is to be removed in MySQL 5.8"

//#else

/*

Default value TRUE for the EMBEDDED_LIBRARY,

default value from Sys_show_compatibility_56 otherwise.

*/

my_bool show_compatibility_56= TRUE;

//#endif /* MYSQL_VERSION_ID >= 50800 */

然后重新编译即可。

3.下载编译需要的软件

# yum -y install gcc gcc-c++ cmake ncurses-devel bsion

4.编译mysql

编译过程中需要用到boost_1_59_0,因为没有安装,所以加上-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local

# cmake -DDOWNLOAD_BOOST=1 \

-DWITH_BOOST=/usr/local \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DENABLED_LOCAL_INFILE=1 \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DMYSQL_TCP_PORT=3306

# make && make install

5.安装mysql

创建mysql用户和组

# groupadd -g 306 mysql

不需要登录也不需要创建家目录

# useradd -u 306 -g 306 -s /bin/false -M mysql

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

初始化

# cd /usr/local/mysql

# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 2>&1 | tee data/mysql_init.log

提示:启动时会生成初始密码,记得查看,忘记了可以查看文件data/mysql_init.log

设置开机启动

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

# chkconfig --add mysql

# chkconfig mysql on

# service mysql start

# grep "temporary password" data/mysql_init.log

2018-10-13T05:25:14.146820Z 1 [Note] A temporary password is generated for root@localhost: f57d_Fp4(Hq#

配置环境变量

# cat > /etc/profile.d/mysql.sh <

export PATH=/usr/local/mysql/bin:$PATH

EOF

# source /etc/profile

6.验证mysql

# mysql -p

Enter password: 输入启动时生成的初始密码f57d_Fp4(Hq#

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 100.100.100

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

可以看到mysql已经启动正常,并且版本是我们自定义的版本信息

5.7版本mysql需要先修改用户密码才能进行下一步操作

mysql> alter user 'root@'localhost' identified by 'db.0easy.com';

Query OK, 0 rows affected (0.00 sec)

查看版本信息

mysql> select @@version;

+-------------+

| @@version |

+-------------+

| 100.100.100 |

+-------------+

1 row in set (0.00 sec)

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值