Mysql5.6.22原始碼安裝

Michael_DD發表於2014-12-23
Mysql5.6.22原始碼安裝


1 環境介紹
作業系統:redhat6.4  64bit


2 安裝軟體
採用原始碼安裝方式
1. mysql安裝包:mysql-5.6.22.tar.gz
Mysql 下載地址:http://dev.mysql.com/downloads/
2. Cmake安裝包
mysql5.5以後是透過cmake來編譯的
wget
cmake-2.8.4.tar.gz


3 刪除Linux自帶的Mysql
如果已經安裝了Mysql其他版本,先刪除
3.1 檢查是否安裝了MySQL
[root@test /]# rpm -qa | grep -i mysql
mysql-libs-5.1.52-1.el6_0.1.i686
qt-mysql-4.6.2-20.el6.i686
mysql-server-5.1.52-1.el6_0.1.i686
mysql-5.1.52-1.el6_0.1.i686
perl-DBD-MySQL-4.013-3.el6.i686
3.2 使用yum來刪除MySQL
[root@test ~]# yum -y remove  mysql-libs-5.1.52-1.el6_0.1.i686
逐個刪除吧!

4 伺服器上安裝Mysql

4.1 先安裝cmake
[root@test ]# tar -zxvf cmake-2.8.4.tar.gz
[root@test ]# cd cmake-2.8.4
[root@test ]# ./configure
[root@test ]# make
[root@test ]# make install

4.2 建立mysql的安裝目錄及資料存放目錄
[root@test cmake-2.8.4]# mkdir /mysql         //安裝mysql
[root@test cmake-2.8.4]# mkdir /mysql/data    //存放資料


4.3 建立mysql使用者及使用者組
[root@test cmake-2.8.4]# groupadd mysql
[root@test cmake-2.8.4]# useradd mysql -g mysql
賦予資料存放目錄許可權:
chown mysql:mysql -R /mysql

4.4 編譯安裝mysql
 編譯
[root@test tmp]# tar -zxvf mysql-5.6.22.tar.gz
[root@test tmp]# cd mysql-5.6.22
[root@test mysql-5.6.22]#cmake . -DCMAKE_INSTALL_PREFIX=/mysql -DMYSQL_DATADIR=/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1

引數說明:
 CMAKE_INSTALL_PREFIX : MySQL安裝目錄
 SYSCONFDIR : 配置檔案目錄
 MYSQL_DATADIR :資料庫目錄
 MYSQL_TCP_PORT :資料庫埠
 MYSQL_UNIX_ADDR :安排個目錄放mysql.sock檔案把,可以設定為日誌存放,data存放目錄等位置
 WITH_EXTRA_CHARSETS : 字元
 WITH_SSL       :the type of SSL
 WITH_EMBEDDED_SERVER :Whether to build embedded server (預設:OFF)
 ENABLED_LOCAL_INFILE :Whether to enable LOCAL for LOAD DATA INFILE(預設:OFF)  允許從本地匯入資料
 WITH_INNOBASE_STORAGE_ENGINE:  1

引數詳細見:http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html

如果發生錯誤檢視:
。。。/mysql-5.6.15/CMakeFiles下的CMakeError.log、CMakeOutput.log檔案
注意事項:
重新編譯時,需要清除舊的物件檔案和快取資訊。
# rm -f CMakeCache.txt


錯誤:Curses library not found. Please install appropriate package
解決辦法:
make clean
rm -rf /etc/my.cnf
rm -f CMakeCache.txt
yum -y install ncurses-devel


安裝
[root@test mysql-5.6.15]# make
[root@test mysql-5.6.15]# make install

4.5 初始化資料庫
[root@test mysql]# cd /mysql
[root@test mysql]# mkdir etc
[root@test mysql]# mkdir log
[root@test mysql]# chown -R mysql:mysql .
[root@test scripts]# cd /mysql/scripts
[root@test scripts]# ./mysql_install_db --user=mysql --basedir=/mysql/ --datadir=/mysql/data/
Installing MySQL system tables...2014-12-23 11:26:21 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-12-23 11:26:21 24207 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-12-23 11:26:21 24207 [Note] InnoDB: The InnoDB memory heap is disabled
2014-12-23 11:26:21 24207 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-12-23 11:26:21 24207 [Note] InnoDB: Memory barrier is not used
2014-12-23 11:26:21 24207 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-12-23 11:26:21 24207 [Note] InnoDB: Using Linux native AIO
2014-12-23 11:26:21 24207 [Note] InnoDB: Using CPU crc32 instructions
2014-12-23 11:26:21 24207 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-12-23 11:26:21 24207 [Note] InnoDB: Completed initialization of buffer pool
2014-12-23 11:26:21 24207 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-12-23 11:26:21 24207 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-12-23 11:26:21 24207 [Note] InnoDB: Database physically writes the file full: wait...
2014-12-23 11:26:21 24207 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-12-23 11:26:21 24207 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-12-23 11:26:22 24207 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-12-23 11:26:22 24207 [Warning] InnoDB: New log files created, LSN=45781
2014-12-23 11:26:22 24207 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-12-23 11:26:22 24207 [Note] InnoDB: Doublewrite buffer created
2014-12-23 11:26:22 24207 [Note] InnoDB: 128 rollback segment(s) are active.
2014-12-23 11:26:22 24207 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-12-23 11:26:22 24207 [Note] InnoDB: Foreign key constraint system tables created
2014-12-23 11:26:22 24207 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-12-23 11:26:22 24207 [Note] InnoDB: Tablespace and datafile system tables created.
2014-12-23 11:26:22 24207 [Note] InnoDB: Waiting for purge to start
2014-12-23 11:26:22 24207 [Note] InnoDB: 5.6.22 started; log sequence number 0
2014-12-23 11:26:25 24207 [Note] Binlog end
2014-12-23 11:26:25 24207 [Note] InnoDB: FTS optimize thread exiting.
2014-12-23 11:26:25 24207 [Note] InnoDB: Starting shutdown...
2014-12-23 11:26:26 24207 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2014-12-23 11:26:26 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-12-23 11:26:26 24229 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-12-23 11:26:26 24229 [Note] InnoDB: The InnoDB memory heap is disabled
2014-12-23 11:26:26 24229 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-12-23 11:26:26 24229 [Note] InnoDB: Memory barrier is not used
2014-12-23 11:26:26 24229 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-12-23 11:26:26 24229 [Note] InnoDB: Using Linux native AIO
2014-12-23 11:26:26 24229 [Note] InnoDB: Using CPU crc32 instructions
2014-12-23 11:26:26 24229 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-12-23 11:26:26 24229 [Note] InnoDB: Completed initialization of buffer pool
2014-12-23 11:26:26 24229 [Note] InnoDB: Highest supported file format is Barracuda.
2014-12-23 11:26:26 24229 [Note] InnoDB: 128 rollback segment(s) are active.
2014-12-23 11:26:26 24229 [Note] InnoDB: Waiting for purge to start
2014-12-23 11:26:26 24229 [Note] InnoDB: 5.6.22 started; log sequence number 1625977
2014-12-23 11:26:27 24229 [Note] Binlog end
2014-12-23 11:26:27 24229 [Note] InnoDB: FTS optimize thread exiting.
2014-12-23 11:26:27 24229 [Note] InnoDB: Starting shutdown...
2014-12-23 11:26:28 24229 [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:

  /mysql//bin/mysqladmin -u root password 'new-password'
  /mysql//bin/mysqladmin -u root -h test password 'new-password'

Alternatively you can run:

  /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 . ; /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

The latest information about MySQL is available on the web at

 

Support MySQL by buying support/licenses at

New default config file was created as /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

[root@test scripts]#

#
#
#

[root@test scripts]# cd /mysql
[root@test mysql]# chown -R root .
[root@test mysql]# chown -R mysql data
[root@test mysql]#  bin/mysqld_safe --user=mysql &
[root@testdb1 mysql]#  bin/mysqld_safe --user=mysql &
[1] 24329
[root@testdb1 mysql]# 141223 11:30:32 mysqld_safe Logging to '/mysql/data/test.err'.
141223 11:30:32 mysqld_safe Starting mysqld daemon with databases from /mysql/data



4.6 配置資料庫
    修改密碼:
[root@test mysql]#  bin/mysqladmin -u root password 'mysql'
Warning: Using a password on the command line interface can be insecure.
[root@test mysql]# ps -ef | grep mysql
root     24329 23025  0 11:30 pts/0    00:00:00 /bin/sh bin/mysqld_safe --user=mysql
mysql    24426 24329  0 11:30 pts/0    00:00:00 /mysql/bin/mysqld --basedir=/mysql --datadir=/mysql/data --plugin-dir=/mysql/lib/plugin --user=mysql --log-error=/mysql/data/testdb1.err --pid-file=/mysql/data/testdb1.pid
root     24496 23025  0 11:32 pts/0    00:00:00 grep mysql
[root@test mysql]# bin/mysql -u root -pmysql
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.22 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>

[root@test mysql]# cp support-files/mysql.server /etc/init.d/
[root@test mysql]# cp support-files/my-default.cnf  etc/my.cnf


編輯etc/my.cnf,zai [mysqld]下增加lower_case_table_names=1
設定環境:
[root@test mysql]# cd /etc
[root@test etc]# vi profile
在檔案最後增加:
PATH=/opt/mysql/bin:/opt/mysql/lib:$PATH
export PATH

生效環境變數:
[root@test etc]# source profile


4.7 手工啟動資料庫
[root@test etc]# service mysql.server status
 SUCCESS! MySQL running (24426)
[root@test etc]# service mysql.server stop
Shutting down MySQL..141223 11:37:29 mysqld_safe mysqld from pid file /mysql/data/testdb1.pid ended
 SUCCESS!
[1]+  Done                    bin/mysqld_safe --user=mysql  (wd: /mysql)
(wd now: /etc)
[root@test etc]# service mysql.server start
Starting MySQL. SUCCESS!
[root@test etc]#


4.8 設定自動啟動
[root@test mysql]# chkconfig --level 35 mysql.server on
[root@test mysql]# chkconfig | grep mysql
mysql.server    0:off   1:off   2:on    3:on    4:on    5:on    6:off

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1377052/,如需轉載,請註明出處,否則將追究法律責任。

相關文章