ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

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

2019-07-21 15:37:45  阅读:223  来源: 互联网

标签:LTS 5.7 mysql etc usr install MySQL local


原文链接: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

标签:LTS,5.7,mysql,etc,usr,install,MySQL,local
来源: https://blog.csdn.net/weixin_30642029/article/details/96725913

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有