Detailed process of MySQL5.6.12 compilation and installation by source code

Source: Internet
Author: User
Tags crc32 crypt localhost mysql automake

1 download the installation package download tar.gz
Wget http://download.csdn.net/detail/mchdba/7545037

2. Install the cmake Software Package
Yum install cmake-y

3 create account of mysql
Groupadd mysql
Useradd-g mysql
Autoreconf -- force -- install
Libtoolize -- automake -- force
Automake -- force -- add-missing

4 complie the sources
Data Directory:/home/data/mysql/data
Mysql software Directory:/usr/local/mysql
Mkdir-p/home/data/mysql/data
Mkdir-p/usr/local/mysql
Tar-xvf mysql-5.6.12.tar.gz
Cd mysql-5.6.12

5 pre-compile
[Root @ squid-2 mysql-5.6.12] # time cmake. -DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/home/data/mysql/data-DWITH_INNOBASE_STORAGE_ENGINE = 1-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock-DMYSQL_USER = mysql-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci
......
-- Check size of wint_t
-- Check size of wint_t-done
-- Cocould NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline. cmake: 85 (MESSAGE ):
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.
Call Stack (most recent call first ):
Cmake/readline. cmake: 128 (FIND_CURSES)
Cmake/readline. cmake: 202 (MYSQL_USE_BUNDLED_EDITLINE)
CMakeLists.txt: 325 (MYSQL_CHECK_EDITLINE)

-- Refreshing incomplete, errors occurred!
Real0m41.872s
User0m23.508s
Sys0m16.328s

6 yum install make
OK
[Root @ 472322 mysql-5.6.13] #
[Solution]
Delete txt
[Root @ squid-2 mysql-5.6.12] # find/-name CMakeCache.txt
/Root/mysql/mysql-5.6.12/CMakeCache.txt

Install ncurses-devel
Yum-y install ncurses-devel

The following error is returned:
-- Specify Ming Test HAVE_PEERCRED
CMake Error at/usr/share/cmake/Modules/CMakeCXXInformation. cmake: 17 (GET_FILENAME_COMPONENT ):
Get_filename_component called with incorrect number of arguments
Call Stack (most recent call first ):
CMakeLists.txt: 3 (PROJECT)


CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Specify Ming Test HAVE_PEERCRED-Failed
-- Library mysqlclient depends on OSLIBS-lpthread; m; rt; dl
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake.-DENABLE_DOWNLOADS = 1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy = http://foo.bar.com: 80
Warning: Bison executable not found in PATH
-- Library mysqlserver depends on OSLIBS-lpthread; m; rt; crypt; dl
-- Refreshing incomplete, errors occurred!

Real0m42.841s
User0m24.527s
Sys0m16.543s
-- Refreshing incomplete, errors occurred!

Real 0m0. 510 s
User 0m0. 275 s
Sys 0m0. 112 s
[Root @ 472322 mysql-5.6.13] #
Yum install gcc-c ++-y
Yum install-y ncurses-devel.x86_64
Yum install-y cmake. x86_64
Yum install-y libaio. x86_64
Yum install-y bison. x86_64
Yum install-y gcc-c ++. x86_64
[Solution]: Delete the original mysql-5.6.12directory and decompress the tar.gz package.

8. Re-execute the compilation
Rm-rf/root/mysql-5.6.12
Cd/root/
Tar-xvf mysql-5.6.12.tar.gz
Cd/root/mysql-5.6.12
Time cmake. -DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/home/data/mysql/data-DWITH_INNOBASE_STORAGE_ENGINE = 1-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock-DMYSQL_USER = mysql-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci
......
-- Looking for asprintf-found
-- Check size of pthread_t
-- Check size of pthread_t-done
-- Using cmake version 2.6.4
-- Not building NDB
-- Specify Ming Test HAVE_PEERCRED
-- Specify Ming Test HAVE_PEERCRED-Success
-- Library mysqlclient depends on OSLIBS-lpthread; m; rt; dl
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake.-DENABLE_DOWNLOADS = 1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy = http://foo.bar.com: 80
-- Library mysqlserver depends on OSLIBS-lpthread; m; rt; crypt; dl
-- Processing ing done
-- Generating done
-- Build files have been written to:/root/mysql/mysql-5.6.12

Real0m45.943s
User0m26.213s
Sys0m17.661s

Time make
This step takes a long time and requires patience to check whether error information is generated.
We will see a lot of Building information.
......
[2, 38%] Building CXX object storage/innobase/CMakeFiles/innobase. dir/lock/lock0iter. cc. o
[38%] Building CXX object storage/innobase/CMakeFiles/innobase. dir/lock/lock0lock. cc. o
[2, 38%] Building CXX object storage/innobase/CMakeFiles/innobase. dir/lock/lock0wait. cc. o
[38%] Building CXX object storage/innobase/CMakeFiles/innobase. dir/log/log0log. cc. o
[39%] Building CXX object storage/innobase/CMakeFiles/innobase. dir/log/log0recv. cc. o
[39%] Building CXX object storage/innobase/CMakeFiles/innobase. dir/mach/mach0data. cc. o
[2, 39%] Building CXX object storage/innobase/CMakeFiles/innobase. dir/mem/mem0mem. cc. o
......
[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

Real21m39.375s
User18m9.239s
Sys1m34.320s

Time make install
This command is faster
......
-- Installing:/usr/local/mysql/man/man8/mysqld.8
-- Installing:/usr/local/mysql/support-files/solaris/postinstall-solaris

Real0m8.439s
User0m3.353s
Sys0m4.616s

9 init db, initialize the database
Ll/home/data/mysql/data
Cd/home/data/mysql/data
Grant mysql folder permissions first
Chown-R mysql/home/data/mysql/data
Chgrp-R mysql/home/data/mysql/data
Chown-R mysql/usr/local/mysql/
Chgrp-R mysql/usr/local/mysql/
Cd/usr/local/mysql/
Cp support-files/my-default.cnf/etc/my56.cnf
Scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/home/data/mysql/data -- defaults-file =/usr/local/mysql/my. cnf
[Root @ localhost mysql] # scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/home/data/mysql/data -- defaults-file =/ usr/local/mysql/my. cnf
Installing MySQL system tables... /usr/local/mysql/bin/mysqld: File '/home/data/mysql/binlog/mysql-bin.index' not found (Errcode: 2-No such file or directory)
10:47:14 9686 [ERROR] Aborting

10:47:14 9686 [Note] Binlog end
10:47:14 9686 [Note]/usr/local/mysql/bin/mysqld: Shutdown complete

[Root @ localhost mysql] # mkdir-p/home/data/mysql/binlog/
[Root @ localhost mysql] #
[Root @ localhost mysql] # chown-R mysql/home/data/mysql/binlog/
[Root @ localhost mysql] # chgrp-R mysql/home/data/mysql/binlog/
Create a directory and execute database initialization:
[Root @ 472322 mysql56] # scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/home/data/mysql/data -- defaults-file =/ usr/local/mysql/my. cnf
Installing MySQL system tables... 2013-08-22 05:06:03 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -- explicit_defaults_for_timestamp server option (see documentation for more details ).
05:06:03 19416 [Note] InnoDB: The InnoDB memory heap is disabled
05:06:03 19416 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
05:06:03 19416 [Note] InnoDB: Compressed tables use zlib 1.2.3
05:06:03 19416 [Note] InnoDB: Using CPU crc32 instructions
05:06:03 19416 [Note] InnoDB: Initializing buffer pool, size = 128.0 M
05:06:03 19416 [Note] InnoDB: Completed initialization of buffer pool
05:06:03 19416 [Note] InnoDB: The first specified data file./ibdata1 did not exist: a new database to be created!
05:06:03 19416 [Note] InnoDB: Setting file./ibdata1 size to 12 MB
05:06:03 19416 [Note] InnoDB: Database physically writes the file full: wait...
05:06:03 19416 [Note] InnoDB: Setting log file./ib_logfile101 size to 48 MB
05:06:03 19416 [Note] InnoDB: Setting log file./ib_logfile1 size to 48 MB
05:06:03 19416 [Note] InnoDB: Renaming log file./ib_logfile101 to./ib_logfile0
05:06:03 19416 [Warning] InnoDB: New log files created, LSN = 45781
05:06:03 19416 [Note] InnoDB: Doublewrite buffer not found: creating new
05:06:03 19416 [Note] InnoDB: Doublewrite buffer created
05:06:03 19416 [Note] InnoDB: 128 rollback segment (s) are active.
05:06:03 19416 [Warning] InnoDB: Creating foreign key constraint system tables.
05:06:03 19416 [Note] InnoDB: Foreign key constraint system tables created
05:06:03 19416 [Note] InnoDB: Creating tablespace and datafile system tables.
05:06:03 19416 [Note] InnoDB: Tablespace and datafile system tables created.
05:06:03 19416 [Note] InnoDB: Waiting for purge to start
05:06:03 19416 [Note] InnoDB: 5.6.13 started; log sequence number 0
05:06:04 19416 [Note] Binlog end
05:06:04 19416 [Note] InnoDB: FTS optimize thread exiting.
05:06:04 19416 [Note] InnoDB: Starting shutdown...
05:06:05 19416 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables... 2013-08-22 05:06:05 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -- explicit_defaults_for_timestamp server option (see documentation for more details ).
05:06:05 19439 [Note] InnoDB: The InnoDB memory heap is disabled
05:06:05 19439 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
05:06:05 19439 [Note] InnoDB: Compressed tables use zlib 1.2.3
05:06:05 19439 [Note] InnoDB: Using CPU crc32 instructions
05:06:05 19439 [Note] InnoDB: Initializing buffer pool, size = 128.0 M
05:06:05 19439 [Note] InnoDB: Completed initialization of buffer pool
05:06:05 19439 [Note] InnoDB: Highest supported file format is Barracuda.
05:06:05 19439 [Note] InnoDB: 128 rollback segment (s) are active.
05:06:05 19439 [Note] InnoDB: Waiting for purge to start
05:06:05 19439 [Note] InnoDB: 5.6.13 started; log sequence number 1625977
05:06:05 19439 [Note] Binlog end
05:06:05 19439 [Note] InnoDB: FTS optimize thread exiting.
05:06:05 19439 [Note] InnoDB: Starting shutdown...
05:06:06 19439 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

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:

/Usr/local/mysql56/bin/mysqladmin-u root password 'new-password'
/Usr/local/mysql56/bin/mysqladmin-u root-h 472322.ea.com password 'new-password'

Alternatively you can run:

/Usr/local/mysql56/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.;/usr/local/mysql56/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
Cd mysql-test; perl mysql-test-run.pl
Please report any problems with the./bin/mysqlbug script!
The latest information about MySQL is available on the web
Http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as/usr/local/mysql56/my. cnf and
Will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file/etc/my. cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use
-- Defaults-file argument to mysqld_safe when starting the server
[Root @ 472322 mysql56] #

10 copy start command
Cp support-files/mysql. server/etc/init. d/mysqld5612
Chmod 700/etc/init. d/mysqld5612
Echo "export PATH = $ PATH:/usr/local/mysql/bin">/etc/profile
Source/etc/profile

11 add boot start
Chkconfig -- add mysqld5612

12 start service
Service mysqld5612 start
[Root @ squid-2 mysql] # service mysqld5612 start
Starting MySQL... The server quit without updating PID f [failed] usr/local/mysql/mysqld. pid ).
[Root @ squid-2 mysql] #
The following error occurs when you view logs:
14:56:54 31726 [Note] Server socket created on IP :'::'.
2014-06-24 14:56:54 31726 [ERROR] Can't start server: Bind on unix socket: Permission denied
2014-06-24 14:56:54 31726 [ERROR] Do you already have another mysqld server running on socket:/usr/local/mysql. sock?
14:56:54 31726 [ERROR] Aborting
The cause is:
/Usr/local/mysql and directory need to grant mysql Permissions
Check the running permission according to the log file, and then check/usr/local/mysql. sock, I found that the file does not exist in the/usr/local/mysql directory. Is there no permission to write the directory?
The/usr/local/mysql directory is the root user, so the mysql operation permission is granted.
Chown-R mysql. mysql/usr/local/mysql
 
[Root @ 472322 data56] # service mysqld5612 start
Starting MySQL. SUCCESS!
[Root @ 472322 data56] # mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 1
Server version: 5.6.13 Source distribution

Copyright (c) 2000,201 3, 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)
Mysql>

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.