科技知识动态:在Centos 5.4上安装社区版Mysql5.1.41_MySQL

导读 跟大家讲解下有关在Centos 5 4上安装社区版Mysql5 1 41_MySQL,相信小伙伴们对这个话题应该也很关注吧,现在就为小伙伴们说说在Centos 5

跟大家讲解下有关在Centos 5.4上安装社区版Mysql5.1.41_MySQL,相信小伙伴们对这个话题应该也很关注吧,现在就为小伙伴们说说在Centos 5.4上安装社区版Mysql5.1.41_MySQL,小编也收集到了有关在Centos 5.4上安装社区版Mysql5.1.41_MySQL的相关资料,希望大家看到了会喜欢。

CentOS

bitsCN.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中文网

免责声明:本文由用户上传,如有侵权请联系删除!