ubuntu18.04下编译mysql5.7源码

1、安装ncurses,bison

sudo apt install libncurses5-dev

sudo apt install bison

2、下载openssl编译

git clone https://github.com/openssl/openssl

3、编译安装

cd mysql-VERSION
mkdir bld
cd bld
cmake .. -DWITH_DEBUG=1 -DWITH_BOOST=/home/wl/boost/boost_1_59_0 -DCMAKE_C_FLAGS="-Wno-implicit-fallthrough" -DCMAKE_CXX_FLAGS="-Wno-implicit-fallthrough"
make
 sudo make install

4、安装后

# Postinstallation setup
cd /usr/local/mysql
 mkdir mysql-files
 chown mysql:mysql mysql-files
 chmod 750 mysql-files
 bin/mysqld --initialize --user=mysql
 bin/mysql_ssl_rsa_setup
 bin/mysqld_safe --user=mysql &
# Next command is optional
 cp support-files/mysql.server /etc/init.d/mysql.server

问题

1、编译时报-Werror=implicit-fallthrough=

需要在cmake时指定编译参数cmake -DCMAKE_C_FLAGS="-Wno-implicit-fallthrough" -DCMAKE_CXX_FLAGS="-Wno-implicit-fallthrough"

2、编译时报没有配套的boost

需要在cmake时指定boost路径-DWITH_BOOST=/home/wl/boost/boost_1_59_0

3、编译时报

Wrong option or path for WITH_SSL=bundled.
Make sure you have specified a supported SSL version.
Valid options are :
system (use the OS openssl library),
yes (synonym for system),
</path/to/custom/openssl/installation>

CMake Error at cmake/ssl.cmake:63 (MESSAGE):
  Please install the appropriate openssl developer package.

Call Stack (most recent call first):
  cmake/ssl.cmake:269 (FATAL_SSL_NOT_FOUND_ERROR)
  CMakeLists.txt:579 (MYSQL_CHECK_SSL)

需要指定openssl路径 -DWITH_SSL=system

4、编译时报

CMake Error: cmake_symlink_library: System Error: Operation not supported
CMake Error: cmake_symlink_library: System Error: Operation not supported
libmysql/CMakeFiles/libmysql.dir/build.make:109: recipe for target 'libmysql/libmysqlclient.so.20.3.16' failed
make[2]: *** [libmysql/libmysqlclient.so.20.3.16] Error 1
make[2]: *** Deleting file 'libmysql/libmysqlclient.so.20.3.16'
CMakeFiles/Makefile2:1290: recipe for target 'libmysql/CMakeFiles/libmysql.dir/all' failed
make[1]: *** [libmysql/CMakeFiles/libmysql.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

这个错误是将源码放在虚拟机共享文件夹中报的(windows下),将其移到虚拟机中解决

发布了1365 篇原创文章 · 获赞 71 · 访问量 140万+

猜你喜欢

转载自blog.csdn.net/wuli2496/article/details/105354219