跟大家講解下有關在Centos 5.4上安裝社區版Mysql5.1.41_MySQL,相信小伙伴們對這個話題應該也很關注吧,現在就為小伙伴們說說在Centos 5.4上安裝社區版Mysql5.1.41_MySQL,小編也收集到了有關在Centos 5.4上安裝社區版Mysql5.1.41_MySQL的相關資料,希望大家看到了會喜歡。
CentOSbitsCN.com在Centos 5.4上安裝社區版Mysql5.1.41
安裝Mysql服務,提供公司內部應用系統數據庫服務。
PC機環境:IntelE5300 內存4G 硬盤500G
操作系統:Linux Centos 5.4
IP:192.168.0.23
2. 安裝準備
shell>yum update –y
shell>yum –y install gcc gcc-c++ perl libtool ncurses-devel
shell>groupadd mysql
shell>useradd -g mysql mysql
3. 安裝
shell>cd /tmp
shell>wgethttp://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.41.tar.gz/from/http://mirror.trouble-free.net/mysql_mirror/
shell>tar zxvf mysql-5.1.41.tar.gz
shell>cd mysql-5.1.41
shell>./configure --prefix=/usr/local/mysql --without-debug--with-extra-charsets=all --with-charset=utf8 --exec-prefix=/usr/local/mysql--with-pthread --enable-assembler --enable-thread-safe-client--with-mysqld-user=mysql --with-plugins=all --with-client-ldflags=-all-static--with-mysqld-ldflags=-all-static --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
shell>make
shell>make install
注:
ec2 安裝mysql參考:錯誤:/usr/bin/ld: cannot find –lncursesw
解決:yum install ncurses-static --with-client-ldflags="-all-static-ltinfo"(configure參數)
注 :make報錯
ERROR 1 : checking for termcap functions library...configure: error: No curses/termcap library found
解決辦法:
Shell>yum list|grep ncurses
Shell>yum -y install ncurses-devel
Shell>yum install ncurses-devel
ERROR 2: checking for termcap functions library... configure: error: No curses/termcaplibrary found
解決辦法:
Shell>yum list|grep ncurses
Shell>yum -y install ncurses-devel
Shell>yum install ncurses-devel
在/tmp/mysql-5.1.53/目錄下
Shell>yum install automake autoconf libtool
Shell>autoreconf --force --install
Shell>libtoolize --automake --force
Shell>automake --force --add-missing
shell>cd /usr/local/mysql
shell>bin/mysql_install_db --user=mysql
shell>chown -R root:mysql .
shell>chown -R mysql /usr/local/mysql
shell>chgrp -R mysql .
shell>cp share/mysql/my-huge.cnf /etc/my.cnf
shell>ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
shell>ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/
shell>ln -s /usr/local/mysql/bin/mysqld_safe /usr/bin/
shell>ln -s /usr/local/mysql/share/mysql/mysql.server/usr/bin/
shell>ln -s /usr/local/mysql/bin/mysqldump /usr/bin/
4. 安裝后配置
4.1. 設置mysql自動啟動腳本
shell>cd /usr/local/mysql
shell>cp ./share/mysql/mysql.server /etc/rc.d/init.d/mysqld
shell>chmod 755 /etc/rc.d/init.d/mysqld
shell>chkconfig –-add mysqld
shell>chkconfig –-level 345 mysqld on
可以使用以下命令啟停mysql服務或查看當前mysql服務狀態
shell>/etc/init.d/mysqld start
shell>/etc/init.d/mysqld stop
shell>/etc/init.d/mysqld status
4.2. 設置root密碼
shell>/usr/local/mysql/bin/mysqladmin –u root password‘password’
4.3. 安裝DBI和DBD
由于需要使用mysqlhotcopy,需要安裝以下部分:
n DBI
shell>cd /tmp
shell>wget http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.609.tar.gz
shell>tar xzvf DBI-1.609.tar.gz
shell>cd DBI-1.609
shell>perl Makefile.PL
shell>make
shell>make install
n DBD::mysql
shell>cd /tmp
shell>wget http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.013.tar.gz
shell>PATH=$PATH:/usr/local/mysql/bin;export PATH
shell>LD_LIBRARY_PATH=/usr/local/mysql/lib/mysql;exportLD_LIBRARY_PATH
shell>unset LANG
shell>tar xzvf DBD-mysql-4.013.tar.gz
shell>cd DBD-mysql-4.013
shell>perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config--testuser=root --testpassword= --testhost=localhost--testdb=mysql
shell>make
shell>make test
shell>make install
測試mysqlhotcopy:
shell>mysqlhotcopy -h localhost -u root -p test/tmp
當出現以下類似結果時,表示mysqlhotcopy可以正常使用:
'test' is an empty database
No tables to hot-copy at /usr/local/mysql/bin/mysqlhotcopy line380.
或者:
Locked 1 tables in 0 seconds.
Flushed tables (`test`.`test`) in 0 seconds.
Copying 3 files...
Copying indices for 0 files...
Unlocked tables.
mysqlhotcopy copied 1 tables (3 files) in 0 seconds (0 secondsoverall).
4.4. 安裝mysql UDF(可選)
由于系統需要,需要能在mysql中調用外部命令,通過安裝以下mysql模塊就可以實現。
下載源代碼:
http://www.mysqludf.org/lib_mysqludf_sys/lib_mysqludf_sys_0.0.3.tar.gz
shell>tar -zxvflib_mysqludf_sys_0.0.3.tar.gz
shell>vim Makefile
注:修改Makefile中gcc參數
原參數為:gcc -Wall -I/usr/include/mysql-I. -shared lib_mysqludf_sys.c -o $(LIBDIR)/lib_mysqludf_sys.so
修改為:gcc -Wall -I/usr/local/mysql/include/mysql-I. -shared lib_mysqludf_sys.c -o /usr/local/mysql/lib/mysql/plugin/lib_mysqludf_sys.so-fPIC
shell>./install.sh
注:編譯完成后會連接mysql數據庫,建立mysql函數。腳本會提示輸入mysql的root用戶密碼。
測試mysqlUDF
登錄mysql數據庫,運行一下SQL語句
mysql> select sys_eval("echohelloworld");
返回以下結果表示UDF建立成功。
+-----------------------------+
| sys_eval("echohelloworld") |
+-----------------------------+
| helloworld
|
+-----------------------------+
1 row in set (0.05 sec)
bitsCN.com來源:php中文網