源代码安装MySQL5.6

环境:

CENTOS5.11

MySQL5.6.21

先安装必要的包

yum -y install make gcc-c++ cmake bison-devel  ncurses-devel


下载MySQL5.6源码包

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.21.tar.gz


解压后编译


tar zxvf mysql-5.6.21.tar.gz 

cmake \
-DCMAKE_INSTALL_PREFIX=/u01/mysql \
-DMYSQL_DATADIR=/u01/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci




......
-- 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://example.com:80
Warning: Bison executable not found in PATH
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- Configuring done
-- Generating done
-- Build files have been written to: /u01/mysql-5.6.21



make

......
Scanning dependencies of target mysqltest_embedded
[ 99%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
Linking CXX executable mysqltest_embedded
[ 99%] 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



make install 

......
-- Installing: /u01/mysql/sql-bench/innotest1
-- Installing: /u01/mysql/sql-bench/innotest2b
-- Installing: /u01/mysql/sql-bench/test-insert
-- Installing: /u01/mysql/sql-bench/run-all-tests
-- Installing: /u01/mysql/sql-bench/README
-- Installing: /u01/mysql/sql-bench/innotest2a
-- Installing: /u01/mysql/sql-bench/test-big-tables
-- Installing: /u01/mysql/sql-bench/test-wisconsin
-- Installing: /u01/mysql/sql-bench/crash-me
-- Installing: /u01/mysql/sql-bench/test-transactions
-- Installing: /u01/mysql/sql-bench/bench-init.pl



创建用户和组

groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql /u01






安装数据库

 ./mysql_install_db --basedir=/u01/mysql --datadir=/u01/mysql/data --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:

  /u01/mysql/bin/mysqladmin -u root password 'new-password'
  /u01/mysql/bin/mysqladmin -u root -h centos511 password 'new-password'

Alternatively you can run:

  /u01/mysql/bin/mysql_secure_installation

which will 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 . ; /u01/mysql/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 at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

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



/u01/mysql/my.cnf使用默认即可






打开mysql数据库
/u01/mysql/bin/mysqld_safe --defaults-file=/u01/mysql/my.cnf

141127 22:18:49 mysqld_safe Logging to '/u01/mysql/data/centos511.err'.
141127 22:18:49 mysqld_safe Starting mysqld daemon with databases from /u01/mysql/data



登陆
/u01/mysql/bin/mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.21 Source distribution

Copyright (c) 2000, 2014, 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> 



安装完成

你可能感兴趣的:(源代码安装MySQL5.6)