install mysql from source and troubleshooting example

Posted maxyang2008

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了install mysql from source and troubleshooting example相关的知识,希望对你有一定的参考价值。

I tried to install mysql 5.7 from source file and upgrading previous MySQL version to the lastest 5.7.22.

following command record is shared as a note.

not many explanations. If having  any questions, you can make a comment and I will reply when I see it.

 

## REFERENCE
https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html#option_cmake_download_boost

## install tools
yum install make gcc-c++ cmake bison-devel ncurses-devel

## create user and dir
id mysql
mkdir /usr/local/mysql
mkdir -p /data/mydb

chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /data/mydb

## unzip source package
cd /home/maxwellyang/Desktop/mysql-dev/source_code
tar -zxvf mysql-5.7.22.tar.gz

## make clean
cd mysql-5.7.22
make clean

## run cmake
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ # install dir
-DMYSQL_DATADIR=/data/mydb \ # data dir
-DSYSCONFDIR=/etc \ # my.cnf dir
-DEFAULT_CHARSET=utf8mb4 \ 
-DDEFAULT_COLLATION=utf8mb4_general_ci -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDOWNLOAD_BOOST=1 \ # auto download boost library file
-DWITH_BOOST=/home/maxwellyang/Desktop/mysql-dev/source_code/boost \ # boost library save dir
-DINSTALL_LAYOUT=STANDALONE


make

make install

## problem encountered after using the compiled version
/etc/init.d/mysqld start # execute failed without writing to mysql error log
bash -x /etc/init.d/mysqld start # to see where script stopped, suspect script maybe error out at /usr/local/mysql/bin/mysqld_safe --datadir=/data/mydb --pid-file=/data/mydb/mysql-dev.pid

bash -x /usr/local/mysql/bin/mysqld_safe --datadir=/data/mydb --pid-file=/data/mydb/mysql-dev.pid # suspect script maybe error out at /usr/local/mysql/bin/mysqld  --basedir=/usr/local/mysql --datadir=/data/mydb --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql  --log-error=/data/mydb/3306.err --pid-file=/data/mydb/mysql-dev.pid --port=3306

/usr/local/mysql/bin/mysqld  --basedir=/usr/local/mysql --datadir=/data/mydb --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql  --log-error=/data/mydb/3306.err --pid-file=/data/mydb/mysql-dev.pid --port=3306 # this script error with [ERROR] COLLATION utf8mb4_general_ci is not valid for CHARACTER SET latin1

# now we see problem is related to collation and characterset.
# my previous database charset is latin1, which is the default charset when installing with tar.gz package
# but the default collation for the compiled version is utf8mb4_general_ci, which is not compatible with charset latin1
# plus I dont specify collation-server paramter in /etc/my.cnf
# so one solution is to specify collation-server parameter in /etc/my.cnf, 1 usable options is collation-server=latin1_german1_ci
# then the above /usr/local/mysql/bin/mysqld script can success
# tried the /etc/init.d/mysqld start, can work also.

 

以上是关于install mysql from source and troubleshooting example的主要内容,如果未能解决你的问题,请参考以下文章

Installing TensorFlow from Source

How to Build MySQL from Source Code on Windows & compile MySQL on win7+vs2010

安装Python 库软件时提示"setuptools must be installed to install from a source distribution"错误(示例代码

linux下从源代码安装git的问题(install from source)

将 node-gyp 标志传递给包时, yarn add package --build-from-source 的行为是不是类似于 npm install package --build-from-

Source Install MySQL5.7.20