Linux source-based installation of MySQL 5.6

Source: Internet
Author: User
Tags readline

MySQL is an open source database, so it can be installed based on source code. There is more flexibility in source-based installation. That is to say we can choose the right compiler for our own hardware platform to optimize the compiled binary code, according to different software platform environment to adjust the relevant compilation parameters, choose their own need to choose different installation components, set the required character set and so on some of the various adjustments can be made according to specific application scenarios. This article describes how to install MySQL in source mode.

1. Installation Environment and media
#安装环境
szdb:~ # Cat/etc/issue
Welcome to SUSE Linux Enterprise Server SP3 (x86_64)-Kernel \ R (\l).
szdb:~ # Uname-a
Linux szdb 2.6.16.60-0.54.5-smp #1 SMP Fri Sep 4 01:28:03 UTC x86_64 x86_64 x86_64 gnu/linux

#安装介质, you can download the installation media to the following URL, note that when downloading, select Source code, the current version is 5.6.17
#根据你自身的环境下载相应的安装介质, the installation media shown in this article is generic Linux (Architecture independent), mysql-5.6.17.tar.gz
http://dev.mysql.com/downloads/mysql/

#源码安装方式官方网站链接: http://dev.mysql.com/doc/refman/5.6/en/installing-source-distribution.html

2. System Requirements
Source installation System Requirements

Installation of MySQL from source requires several development tools. Some of these tools is needed no matter whether you use a standard source distribution or a development source tree. Other tool requirements depend on which installation method.

To install MySQL from source, your system must has the following tools, regardless of installation method:

  • CMake, which is used as the build framework on all platforms. CMake can downloaded from http://www.cmake.org.
  • A Good make program. Although some platforms come with their own make implementations, it's highly recommended that's use GNU make 3.75 or n Ewer. It may already is available on your system as gmake. GNU make are available from http://www.gnu.org/software/make/.
  • A working ANSI C + + compiler. GCC 4.2.1 or later, Sun Studio or later, Visual Studio or later, and many current vendor-supplied compilers is kn own to work.
  • Perl is needed if you intend to run test scripts. Most unix-like systems include Perl. On Windows, you can use a version such as ActiveState Perl.

#使用源码安装上面的一些开发工具是需要的, the more important one is the CMake tool, which typically does not have an OS installed and requires manual installation.
#如果没有cmake会收到这个错误提示: (-bash:cmake:command not found)

3, installation CMake
#可以到这里下载cmake, I downloaded here is 2.6.4 version
Http://www.cmake.org/cmake/resources/software.html
szdb:~ # CD/USR/LOCAL/SRC/MYSQL_SRC
SZDB:/USR/LOCAL/SRC/MYSQL_SRC # TAR-XVF cmake-2.6.4.tar.gz
SZDB:/USR/LOCAL/SRC/MYSQL_SRC # CD cmake-2.6.4
szdb:/usr/local/src/mysql_src/cmake-2.6.4 # ./bootstrap
szdb:/usr/local/src/mysql_src/cmake-2.6.4 # ./make
szdb:/usr/local/src/mysql_src/cmake-2.6.4 # ./make Install

szdb : ~ # groupadd MySQL
szdb:~ # useradd-r-G MySQL MySQL
szdb:~ # cd/usr/local/src/mysql_src
szdb:/usr/local/src/ MYSQL_SRC # TAR-XVF mysql-5.6.17.tar.gz
szdb:/usr/local/src/mysql_src # Span style= "color: #990000;" >ls
mysql-5.6.17  mysql-5.6.17.tar.gz
Szdb:/usr/local/src/mysql_src # cd mysql-5.6.17/
szdb:/usr/local/src/mysql_src/mysql-5.6.17 # cmake.

             ..........
 --Check size of Wint_t-done
 --Could not find curses  (missing:  curses_library curses_i Nclude_path)
  CMake Error at cmake/readline.cmake:85 (MESSAGE):                  Author:leshami
    Curses Library not found.  Please install appropriate package,  blog  : Http://blog.csdn.net/leshami

Remove CMakeCache.txt and rerun CMake. On Debian/ubuntu, package name is Libncurses5-dev,
On Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:128 (find_curses)
cmake/readline.cmake:202 (Mysql_use_bundled_editline)
cmakelists.txt:411 (Mysql_check_editline)

#如果cmake期间碰到上述错误, the Ncurses-devel RPM package should be installed and then removed CMakeCache.txt
--Configuring incomplete, Errors occurred!

#如有没有对应的os安装光盘, you can download the RPM package from the link below, noting that the corresponding version number should be the same
http://www.filewatcher.com/m/ncurses-devel-5.5-18.11.x86_64. rpm.735840-0.html
SZDB:/USR/LOCAL/SRC/MYSQL_SRC # RPM-UVH ncurses-devel-5.5-18.11.x86_64.rpm
preparing...                 ########################################### [100%]
   1:ncurses-devel           ########################################### [100%]

szdb:/usr/local/src/mysql_src/mysql-5.6.17 # RM-RF CMakeCache.txt
szdb:/usr/local/src/mysql_src/mysql-5.6.17 # CMake. #再次执行cmake

........
--Library MySQLServer depends on Oslibs-lpthread;m;rt;crypt;dl;aio
--Configuring done
--Generating done
--Build files has been written to:/usr/local/src/mysql_src/mysql-5.6.17

szdb:/usr/local/src/mysql_src/mysql-5.6.17 # make

   linking CXX executable mysqltest_embedded
    [100%] Built target mysqltest_embedded
   scanning dependencies of Target My_safe_ Process
   [100%] Building CXX Object Mysql-test/lib/my/safeprocess/cmakefiles/my_safe_ PROCESS.DIR/SAFE_PROCESS.CC.O
   linking CXX executable my_safe_process
   [ 100%] Built target my_safe_process

szdb:/usr/local/src/mysql_src/mysql-5.6.17 # make Install
szdb:/usr/local/src/mysql_src/mysql-5.6.17 # Cd/usr/local/mysql
Szdb:/usr/local/mysql # Chown-r MySQL.
Szdb:/usr/local/mysql # Chgrp-r MySQL.
Szdb:/usr/local/mysql # scripts/mysql_install_db--user=mysql

..........
To start mysqld at boot time with to copy
Support-files/mysql.server to the right place for your system

REMEMBER to SET A PASSWORD for the MySQL root USER!
To does so, start the server, then issue the following commands:

./bin/mysqladmin-u root password ' new-password '
./bin/mysqladmin-u root-h szdb password ' new-password '

Alternatively you can run:

./bin/mysql_secure_installation

Which would also give you the option of removing the test
Databases and anonymous user created by default. This is
Strongly recommended for production servers.

See the Manual for more instructions.

You can start the MySQL daemon with:

Cd. ;./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

CD mysql-test; Perl mysql-test-run.pl

New Default Config file was created as./my.cnf and
Would be used by default by the server when you start it.
You could edit this file to the Change server settings
..........

Szdb:/usr/local/mysql #chown-r Root.
Szdb:/usr/local/mysql #chown-r MySQL Data
Szdb:/usr/local/mysql #CP Support-files/mysql.server/etc/init.d/mysql.server#配置自启动
Szdb:/usr/local/mysql #CP support-files/my-default.cnf/etc/my.cnf#添加缺省的my. CNF configuration file
Szdb:/usr/local/mysql #bin/mysqld_safe--user=mysql &#启动mysql
[1] 21004
Szdb:/usr/local/mysql # 140521 02:54:54 mysqld_safe Logging to '/usr/local/mysql/data/szdb.err '.
140521 02:54:54 Mysqld_safe starting mysqld daemon with databases From/usr/local/mysql/data

#配置环境变量, implemented via a soft-chain or modified environment variable (path= $PATH:/usr/local/mysql/bin/;export PATH)

szdb:~ # Ln-fs/usr/local/mysql/bin/mysql/usr/local/bin
szdb:~ # Ln-fs/usr/local/mysql/bin/mysqladmin/usr/local/bin
szdb:~ # Ln-fs/usr/local/mysql/bin/mysqld_safe/usr/local/bin

#登陆到mysql
Szdb:/usr/local/bin # Mysql-uroot
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server version:5.6.17 Source Distribution

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

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

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

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| Test |
+--------------------+
4 rows in Set (0.00 sec)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.