[Original] install MySQL5.6 _ MySQL based on source code in Linux

Source: Internet
Author: User
Tags visual studio 2010
[Original] install MySQL5.6 MySQL as an open source database based on the source code in Linux. Therefore, you can install MySQL based on the source code. Source code-based installation provides more flexibility. That is to say, we can select a suitable compiler for our hardware platform to optimize the compiled binary code and adjust the relevant compilation parameters according to the environment of different software platforms, select different installation components and set the desired character set. you can make various adjustments based on specific application scenarios. This article describes how to install MySQL in the source code mode.

1. installation environment and media
# Installation environment
SZDB :~ # Cat/etc/issue
Welcome to SUSE Linux Enterprise Server 10 SP3 (x86_64)-Kernel/r (/l ).
SZDB :~ # Uname-
Linux SZDB 2.6.16.60-0.54.5-smp #1 SMP Fri Sep 4 01:28:03 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux

# Install media. you can download the installation media at the following URL. select source code when downloading. The current version is 5.6.17.
# Download the corresponding installation media according to your own environment, the installation media demonstrated in this article is Generic Linux (Architecture Independent), mysql-5.6.17.tar.gz
Http://dev.mysql.com/downloads/mysql/

# Source code installation method official website link: 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 are needed no matter whether you use a standard source distribution or a development source tree. other tool requirements depend on which installation method you use.

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

A, CMake, which is used as the build framework on all platforms. CMake can be downloaded fromhttp: // www.cmake.org.

B. A good make program. although some platforms come with their own make implementations, it is highly recommended that you use GNU make 3.75 or newer. it may already be available on your system as gmake. GNU make is available fromhttp: // www.gnu.org/software/make /.

C. A working ansi c ++ compiler. GCC 4.2.1 or later, Sun Studio 12 or later, Visual Studio 2010 or later, and other current vendor-supplied compilers are known to work.

D. 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.

# Install the above development tools using the source code. The most important one is the Cmake tool. Generally, the OS is not installed and must be manually installed.
# If no cmake is available, this error message is displayed: (-bash: cmake: command not found)

3. install cmake
# You can download cmake here. here I download version 2.6.4.
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

4. install MySQL
SZDB :~ # Groupadd mysql
SZDB :~ # Useradd-r-g 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 # ls
Mysql-5.6.17 mysql-5.6.17.tar.gz
SZDB:/usr/local/src/mysql_src # mysql-5.6.17/cd/
SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # cmake.

..........
-- Check size of wint_t-done
-- Cocould NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_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)

# If the above error occurs during cmake, install the ncurses-devel rpmpackage and remove cmakecache.txt.
-- Refreshing incomplete, errors occurred!

# If there is any corresponding OS installation CD, you can download this rpm package from the following link. Note that the corresponding version number should be consistent.
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. # execute cmake again

........
-- Library mysqlserver depends on OSLIBS-lpthread; m; rt; crypt; dl; aio
-- Processing ing done
-- Generating done
-- Build files have 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
[2, 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
[1, 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 you have to copy
Support-files/mysql. server to the right place for your system

Please remember to set a password for the MySQL root USER!
To do 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 will also give you the option of removing the test
Databases and anonymous user created by default. This is
Stronugly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon:

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
Will be used by default by the server when you start it.
You may edit this file to 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 # configure auto-start
SZDB:/usr/local/mysql # cp support-files/my-default.cnf/etc/my. cnf # add the default my. cnf configuration file
SZDB:/usr/local/mysql # bin/mysqld_safe -- user = mysql & # start 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

# Configure environment variables by using soft links or modifying environment variables (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

# Log on to 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) 2000,201 4, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be 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.