CentOS MySQL 5.5 源码安装
一、环境:
系统版本:CentOS5.5
MySQL版本:mysql-5.5.22
二、步骤:
1. 安装需要系统库相关库文件:
[root@localhost ~]# yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib fiex libxml ncurses-devel libmcrypt libtool-ltdl-devel*
2.需要的两个包
[root@localhost /]# cd /usr/local/src/
[root@localhost src]# ll
total 29332
-rw-r--r-- 1 root root 5517977 Jul 11 19:17 cmake-2.8.5.tar.gz
-rw-r--r-- 1 root root 24464834 Jul 11 19:17 mysql-5.5.22.tar.gz
1) 安装cmake
[root@localhost src]# tar zxvf cmake-2.8.5.tar.gz
[root@localhost src]# cd cmake-2.8.5
[root@localhost cmake-2.8.5]# ./bootstrap
…… ……
-- Build files have been written to: /usr/local/src/cmake-2.8.5
---------------------------------------------
CMake has bootstrapped. Now run gmake.
[root@localhost cmake-2.8.5]# gmake
…… ……
[100%] Building CXX object Tests/CMakeLib/CMakeFiles/runcompilecommands.dir/run_compile_commands.cxx.o
Linking CXX executable runcompilecommands
[100%] Built target runcompilecommands
[root@localhost cmake-2.8.5]# gmake install
[root@localhost cmake-2.8.5]# cd ..
2)安装mysql
[root@localhost src]# groupadd mysql
[root@localhost src]# useradd -g mysql mysql
[root@localhost src]# tar zxvf mysql-5.5.22.tar.gz
[root@localhost src]# cd mysql-5.5.22
[root@localhost mysql-5.5.22]#
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql
…… ……
CMake Warning:
Manually-specified variables were not used by the project:
MYSQL_USER
WITH_MEMORY_STORAGE_ENGINE
-- Build files have been written to: /usr/local/src/mysql-5.5.22
[root@localhost mysql-5.5.22]#make
…… ……
[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
[root@localhost mysql-5.5.22]#make install
…… ……
-- Installing: /usr/local/mysql/man/man1/mysql_find_rows.1
-- Installing: /usr/local/mysql/man/man1/mysql_upgrade.1
-- Installing: /usr/local/mysql/man/man1/mysqlimport.1
-- Installing: /usr/local/mysql/man/man1/mysql_client_test.1
-- Installing: /usr/local/mysql/man/man8/mysqld.8
[root@localhost mysql-5.5.22]# chmod +w /usr/local/mysql/
[root@localhost mysql-5.5.22]# chown -R mysql:mysql /usr/local/mysql/
[root@localhost mysql-5.5.22]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
[root@localhost mysql-5.5.22]# mkdir -p /var/mysql
[root@localhost mysql-5.5.22]# mkdir -p /var/mysql/data/
[root@localhost mysql-5.5.22]# mkdir -p /var/mysql/log/
[root@localhost mysql-5.5.22]# chown -R mysql:mysql /var/mysql/
[root@localhost mysql-5.5.22]# cd support-files/
[root@localhost support-files]# cp my-medium.cnf /etc/my.cnf
[root@localhost support-files]# cp mysql.server /etc/init.d/mysql
初始化安装。
[root@localhost support-files]# /usr/local/mysql/scripts/mysql_install_db \
--defaults-file=/etc/my.cnf \
--basedir=/usr/local/mysql \
--datadir=/var/mysql/data \
--user=mysql
…… ……
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 with the /usr/local/mysql/scripts/mysqlbug script!
[root@localhost support-files]# chmod +x /etc/init.d/mysql
[root@localhost support-files]# vi /etc/init.d/mysql
basedir=/usr/local/mysql
datadir=/var/mysql/data
[root@localhost support-files]#chkconfig --add mysql
[root@localhost support-files]#chkconfig --level 345 mysql on
[root@localhost support-files]# cd /usr/local/mysql
[root@localhost mysql]# service mysql start
Starting MySQL.. SUCCESS!
[root@localhost mysql]# mysql
-bash: mysql: command not found
[root@localhost mysql]# /usr/local/mysql/bin/mysql -uroot mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.22 Source distribution
Copyright (c) 2000, 2011, 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.01 sec)
mysql> exit
Bye
[root@localhost mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin
[root@localhost mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.22 Source distribution
Copyright (c) 2000, 2011, 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> grant all privileges on . to root@'%' identified by 'password' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@localhost mysql]# /etc/init.d/iptables stop;
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
三、遇到的问题:
※ -bash: mysql: command not found
原因:
是因为mysql命令的路径在/usr/local/mysql/bin下面,所以你直接使用mysql命令时,系统在/usr/bin下面查此命令,所以找不到了。
解决办法:做个链接即可。
ln -s /usr/local/mysql/bin/mysql /usr/bin
※ Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
错误重现:
该错误会在安装cmake时发生,原因是以为没有执行第一步。当你执行完第一步重做cmake前需要先rm CMakeCache.txt。
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (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:126 (FIND_CURSES)
cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:250 (MYSQL_CHECK_READLINE)
- 版权申明:此文如未标注转载均为本站原创,自由转载请表明出处《博瑞博客》。
- 本文网址:http://blog.neacn.com/Linux/48.html
- 上篇文章:解决MySQL安装时1045错误的方法
- 下篇文章:Serv_U 6.0 用mysql数据库承载用户信息