mysql5.5開始,源碼配置編譯工具configure變成了cmake,所以先要去把cmake裝上。並安裝make,bison,cmake,gcc-c++,ncurses的包
去http://www.cmake.org/cmake/resources/software.html 下載cmake
./cmake-2.8.12.2-Linux-i386.sh --prefix=/usr/local/
ln -s /usr/local/cmake-2.8.12.2-Linux-i386/bin/cmake /usr/bin/cmake
先執行# cmake . -LH 檢查一下cmake查看支持的參數,也可以去http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html 查看編譯時可指定參數的詳細描述,還可以參考安裝文檔里面的這一章節:2.9.4 MySQL Source-Configuration Options。
常用參數如下:
CMAKE_INSTALL_PREFIX:指定MySQL程序的安裝目錄,默認/usr/local/mysql
DEFAULT_CHARSET:指定服務器默認字符集,默認latin1
DEFAULT_COLLATION:指定服務器默認的校對規則,默認latin1_general_ci
ENABLED_LOCAL_INFILE:指定是否允許本地執行LOAD DATA INFILE,默認OFF
WITH_COMMENT:指定編譯備注信息
WITH_xxx_STORAGE_ENGINE:指定靜態編譯到mysql的存儲引擎,MyISAM,MERGE,MEMBER以及CSV四種引擎默認即被編譯至服務器,不需要特別指定。
WITHOUT_xxx_STORAGE_ENGINE:指定不編譯的存儲引擎
SYSCONFDIR:初始化參數文件目錄
MYSQL_DATADIR:數據文件目錄
MYSQL_TCP_PORT:服務端口號,默認3306
MYSQL_UNIX_ADDR:socket文件路徑,默認/tmp/mysql.sock
實際執行時指定的參數如下:
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc\ -DDEFAULT_CHARSET=utf8\ -DDEFAULT_COLLATION=utf8_general_ci\ -DMYSQL_USER=mysql
[root@nosql1 mysql-5.5.37]# cmake . -DCMAKE_INSTALL_PREFIX=/u01/mysql -DMYSQL_DATADIR=/u01/mysql/mysql/data -DSYSCONFDIR=/etc\ > -DDEFAULT_CHARSET=gbk\ > -DDEFAULT_COLLATION=gbk_general_ci\ > -DMYSQL_USER=mysql -- Running cmake version 2.6.4 -- MySQL 5.5.37 -- Packaging as: mysql-5.5.37-Linux-x86_64 -- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:83 (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:127 (FIND_CURSES) cmake/readline.cmake:217 (MYSQL_USE_BUNDLED_LIBEDIT) CMakeLists.txt:355 (MYSQL_CHECK_READLINE) -- Configuring incomplete, errors occurred!
cmake過程中,報了一個這個錯,根據提示安裝ncurses-devel,並find / -name CMakeCache.txt,把列出來的刪除點,重新cmake就行了。
然后接着make
然后再執行make install
編譯完成后,安裝數據庫
[root@ora11g mysql]# ls bin COPYING data docs include INSTALL-BINARY lib man mysql-test README scripts share sql-bench support-files [root@ora11g mysql]# cd scripts/ [root@ora11g scripts]# ls mysql_install_db [root@ora11g scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data Installing MySQL system tables... OK Filling help tables... 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/mysql/bin/mysqladmin -u root password 'new-password' /usr/local/mysql/bin/mysqladmin -u root -h ora11g password 'new-password' Alternatively you can run: /usr/local/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 /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl Please report any problems at http://bugs.mysql.com/ [root@ora11g scripts]#
這一步也可以先修改support-files里面的模板,在模板里面添加上 --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
如果不加basedir和datadir的話,初始化會報錯:
[root@nosql1 scripts]# ./mysql_install_db --defaults-file=../my.cnf --user=mysql FATAL ERROR: Could not find ./bin/my_print_defaults If you compiled from source, you need to run 'make install' to copy the software into the correct location ready for operation. If you are using a binary release, you must either be at the top level of the extracted archive, or pass the --basedir option
在bin下執行,mysql_install_db --default-file=my.cnf --user=mysql
mysql的啟動:
[mysql@ora11g ~]$ cd /usr/local/mysql/bin/ [mysql@ora11g bin]$ ./mysqld mysqld mysqld_multi mysqld_safe mysqldump mysqldumpslow [mysql@ora11g bin]$ ./mysqld_safe --user=mysql & [1] 2244 [mysql@ora11g bin]$ 140327 21:17:41 mysqld_safe Logging to '/usr/local/mysql/data/ora11g.err'. 140327 21:17:41 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data [mysql@ora11g bin]$ [mysql@ora11g bin]$ ps -ef | grep mysql root 2082 1786 0 21:17 pts/2 00:00:00 su - mysql mysql 2083 2082 0 21:17 pts/2 00:00:00 -bash mysql 2244 2083 0 21:17 pts/2 00:00:00 /bin/sh ./mysqld_safe --user=mysql mysql 2496 2244 1 21:17 pts/2 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/ora11g.err --pid-file=/usr/local/mysql/data/ora11g.pid --socket=/tmp/mysql.sock --port=3306 mysql 2579 2083 0 21:17 pts/2 00:00:00 ps -ef mysql 2580 2083 0 21:17 pts/2 00:00:00 grep mysql [mysql@ora11g bin]$
mysql的登錄:
[mysql@ora11g bin]$ ./mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.37 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec) mysql> select version(); +-----------+ | version() | +-----------+ | 5.5.37 | +-----------+ 1 row in set (0.00 sec) mysql>