Install MySQL 5.7.5-m15 on Ubuntu Server 14.04 LTS from Source

原文链接:http://www.cnblogs.com/jeffreyf/p/install-mysql-on-ubuntu-from-source-code.html

This post documents the steps of installing MySQL from source code, and the resolutions to serveral issues in installing. The steps here are specific to 64-bit Ubuntu 14.04.1 LTS, and MySQL source code is 5.7.5-m15. But I think most of them can also work on your system.

 

Download MySQL source code

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.5-m15.tar.gz


Install GCC/G++/Make/CMake

If your system has not installed gcc/g++/make/cmake yet, please install them first. The following commands should be able to get your system installed correct and proper versions.

apt-get install update
apt-get install gcc
apt-get install g++
apt-get install make
apt-get install cmake cmake-gui

 

Other dependencies

If the system prompts "Curses library not found.  Please install appropriate package, remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel." when you execute "cmake .", please run apt-get to install the library.

apt-get install libncurses5-dev

If the error "Bison executable not found in PATH.", please run the command below.

apt-get install bison


Install MySQL 

#
groupadd mysql
useradd -r -g mysql mysql

#
tar zxvf mysql-VERSION.tar.gz
cd mysql-VERSION

#
cmake . -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/boost -DENABLE_DOWNLOADS=1
make
make install

#
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .

# from 5.7.5, the --datadir option is mandatory.
bin/mysql_install_db --datadir=/usr/local/mysql/data

#
chown -R root .
chown -R mysql data 

# Open the MySQL config file
vi /etc/mysql/my.cnf

Change the default values of basedir, datadir, and lc-message-dir to the following values.

basedir  = /usr/local/mysql
datadir  = /usr/local/mysql/data
lc-messages-dir = /usr/local/mysql/share # this setting will avoid the error "[ERROR] Can't find error-message file '/usr/share/mysql/errmsg.sys'".

If your MySQL log is under /var/log/mysql, please execute the following commands. The commands will prevent the error "touch: cannot touch /var/log/mysql/error.log: No such file or directory" from happening when you run "bin/mysqld_safe --user=mysql &".

mkdir /var/log/mysql
chown -R mysql:mysql /var/log/mysql

Run mysqld_safe to try to start mysql. Don't omit the '&'. :-)

bin/mysqld_safe --user=mysql &

If you see the following errors in /var/log/mysql/error.log, open /etc/mysql/my.cnf and edit the variables like below. 

[ERROR] unknown variable 'key_buffer=16M'

vi /etc/mysql/my.cnf, change 'key_buffer=16M' to  'key_buffer_size=16M'.

[ERROR] unknown variable 'myisam-recover=BACKUP'

Comments out this line 'myisam-recover=BACKUP' in /etc/mysql/my.cnf with a '#'.

 

Reset password for root 

First, you need login mysql server with the random password generated by mysql_install_db. You can find the password in the file /root/.mysql_secret.

/usr/local/mysql/bin/mysql -u root -p

Then, use Set Password statement to set new password.

mysql> set password = password('your password');

 

Add MySQL Server executables to system PATH

Create a file mysql.sh under /etc/profile.d/ directory,

touch /etc/profile.d/mysql.sh
vi /etc/profile.d/mysql.sh

and add the following lines to the file.

#!/bin/bash

if ! echo ${PATH} | /bin/grep -q /usr/local/mysql/bin ; then
PATH=/usr/local/mysql/bin:${PATH}
fi

 Use the following command to add the path to the current shell.

source /etc/profile.d/mysql.sh

Use echo $PATH to check if the script works. "/usr/local/mysql/bin" should be in the output.

echo $PATH

 

Add MySQL Server libraries to the shared library cache 

touch /etc/ld.so.conf.d/mysql.conf
echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
ldconfig

 

Set MySQL Server service

cp support-files/mysql.server /etc/init.d/mysql
service mysql start


Add System Startup for MySQL

update-rc.d mysql defaults

 

转载于:https://www.cnblogs.com/jeffreyf/p/install-mysql-on-ubuntu-from-source-code.html

上一篇:《Gradient Outlier Removal for Gradient-Domain Path Tracing》——论文阅读之 patch tracing


下一篇:LTS秘钥协商算法分析