网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Linux下如何安装配置源代码版本的MySQL

这篇文章主要为大家展示了“Linux下如何安装配置源代码版本的MySQL”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“Linux下如何安装配置源代码版本的MySQL”这篇文章吧。

专注于为中小企业提供成都网站设计、做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业鄄城免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了成百上千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。



操作系统版本:Red Hat Enterprise Linux Server release 5 (Tikanga)
MySQL版本:
安装文件:MySQL-community-5.1.45-1.rhel5.src.rpm


 1.释放源代码包

   使用的安装文件是一个source RPM,首先要将其内容释放:

方法一:

[root@redhat5-db-1 software]# rpm -i MySQL-community-5.1.45-1.rhel5.src.rpm
error: cannot create %sourcedir /usr/src/redhat/SOURCES
[root@redhat5-db-1 software]# mkdir -p /usr/src/redhat/SOURCES
[root@redhat5-db-1 software]# rpm -i MySQL-community-5.1.45-1.rhel5.src.rpm
warning: user mysqldev does not exist - using root
warning: group mysqldev does not exist - using root
warning: user mysqldev does not exist - using root
warning: group mysqldev does not exist - using root
[root@redhat5-db-1 software]# ls /usr/src/redhat/*
/usr/src/redhat/SOURCES:
mysql-5.1.45.tar.gz

/usr/src/redhat/SPECS:
mysql-5.1.45.rhel5.spec

[@more@]方法二:

[root@redhat5-db-1 software]# rpm2cpio MySQL-community-5.1.45-1.rhel5.src.rpm | cpio -idmv
mysql-5.1.45.rhel5.spec
mysql-5.1.45.tar.gz
43995 blocks
[root@redhat5-db-1 software]# ls
mysql-5.1.45.rhel5.spec  mysql-5.1.45.tar.gz  MySQL-community-5.1.45-1.rhel5.src.rpm

注:无论使用哪种方法,都会在释放源代码包的同时,释放另一个文件 mysql-5.1.45.rhel5.spec 。它是一个RPM SPEC文件,可以通过rpmbuild命令创建MySQL的源代码文件或二进制程序(-bp选项在 /usr/src/redhat/BUILD 目录下创建源代码文件,-bb选项在 /usr/src/redhat/RPM 目录下创建二进制程序),这里不再赘述。


 2.安装前的准备工作

 1)创建用户和组

[root@redhat5-db-1 software]# groupadd mysql
[root@redhat5-db-1 software]# useradd -g mysql mysql
[root@redhat5-db-1 software]# id mysql
uid=502(mysql) gid=504(mysql) groups=504(mysql)

 2)准备必要的目录

[root@redhat5-db-1 software]# mkdir -p /opt/mysql /data/mysql
[root@redhat5-db-1 software]# chown mysql:mysql /opt/mysql /data/mysql

 3)安装必要的RPM

   需要安装ncurses-devel,否则编译时会报如下错误:

checking for termcap functions library... configure: error: No curses/termcap library found

   在Red Hat EL 5安装光盘中找到该RPM,进行安装:

[root@redhat5-db-1 software]# mount -o ro /dev/cdrom /mnt/cdrom
[root@redhat5-db-1 software]# rpm -ivh /mnt/cdrom/Server/ncurses-devel-5.5-24.20060715.i386.rpm
warning: /mnt/cdrom/Server/ncurses-devel-5.5-24.20060715.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
  1:ncurses-devel          ########################################### [100%]

 4)解压源代码包

[root@redhat5-db-1 software]# tar -zxf mysql-5.1.45.tar.gz
[root@redhat5-db-1 software]# ls -p
mysql-5.1.45/  mysql-5.1.45.rhel5.spec  mysql-5.1.45.tar.gz  MySQL-community-5.1.45-1.rhel5.src.rpm


 3.安装MySQL

 1)CONFIGURE

[root@redhat5-db-1 software]# su - mysql
[mysql@redhat5-db-1 ~]$ cd /opt/software/mysql-5.1.45
[mysql@redhat5-db-1 mysql-5.1.45]$ ./configure --prefix=/opt/mysql --localstatedir=/data/mysql --with-plugins=innobase
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c

......

config.status: executing depfiles commands
config.status: executing libtool commands
/bin/rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands

Thank you for choosing MySQL!

Remember to check the platform specific part of the reference manual
for hints about installing MySQL on your platform.
Also have a look at the files in the Docs directory.

注:--prefix选项指定MySQL程序的路径;--localstatedir选项指定MySQL数据文件的路径;--with-plugins=innobase 指定MySQL服务器包含InnoDB功能。

 2)MAKE

[mysql@redhat5-db-1 mysql-5.1.45]$ make
Making all in .
make[1]: Entering directory `/opt/software/mysql-5.1.45'
make abi_headers="include/mysql/plugin.h include/mysql.h" do_abi_check
make[2]: Entering directory `/opt/software/mysql-5.1.45'

......

Making all in win
make[1]: Entering directory `/opt/software/mysql-5.1.45/win'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/software/mysql-5.1.45/win'

 3)MAKE-INSTALL

[mysql@redhat5-db-1 mysql-5.1.45]$ make install
Making install in .
make[1]: Entering directory `/opt/software/mysql-5.1.45'
make abi_headers="include/mysql/plugin.h include/mysql.h" do_abi_check
make[2]: Entering directory `/opt/software/mysql-5.1.45'

......

Making install in win
make[1]: Entering directory `/opt/software/mysql-5.1.45/win'
make[2]: Entering directory `/opt/software/mysql-5.1.45/win'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/software/mysql-5.1.45/win'
make[1]: Leaving directory `/opt/software/mysql-5.1.45/win'
[mysql@redhat5-db-1 mysql-5.1.45]$ ls /opt/mysql
bin  docs  include  lib  libexec  mysql-test  share  sql-bench


 4.安装后的工作

 1)创建选项文件

[root@redhat5-db-1 ~]# cp /opt/software/mysql-5.1.45/support-files/my-medium.cnf /etc/my.cnf
[root@redhat5-db-1 ~]# chown mysql:mysql /etc/my.cnf

   可以通过修改其内容对MySQL服务器进行配置。这里只简单取消InnoDB相关参数所在行的注释:

# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /data/mysql/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

 2)设置环境变量

   在mysql的HOME目录下的.bash_profile文件中添加如下内容:

# Added by ggyy on March 31st, 2010
PATH=$PATH:/opt/mysql/bin
export PATH

 3)初始化MySQL

[mysql@redhat5-db-1 ~]$ /opt/mysql/bin/mysql_install_db
Installing MySQL system tables...
100331 18:21:59 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
100331 18:22:00 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
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:

/opt/mysql/bin/mysqladmin -u root password 'new-password'
/opt/mysql/bin/mysqladmin -u root -h redhat5-db-1 password 'new-password'

Alternatively you can run:
/opt/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 /opt/mysql ; /opt/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /opt/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/mysql/bin/mysqlbug script!

[mysql@redhat5-db-1 ~]$ ls /data/mysql
mysql  mysql-bin.000001  mysql-bin.000002  mysql-bin.index  test

 3)启动和关闭MySQL

   启动MySQL服务器,测试登陆:

[mysql@redhat5-db-1 ~]$ /opt/mysql/bin/mysqld_safe &
[1] 3028
[mysql@redhat5-db-1 ~]$ 100331 18:27:18 mysqld_safe Logging to '/data/mysql/redhat5-db-1.err'.
100331 18:27:18 mysqld_safe Starting mysqld daemon with databases from /data/mysql

mysql> select version();
+------------+
| version()  |
+------------+
| 5.1.45-log |
+------------+
1 row in set (0.00 sec)

mysql> show variables like "have_innodb";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_innodb   | YES   |
+---------------+-------+
1 row in set (0.00 sec)

   可以使用mysql.server脚本启动和关闭MySQL服务器,它位于解压的源代码目录下的support-files子目录中。该目录下还有许多其它有用的文件、脚本,可以考虑将其复制到MySQL程序目录下,并在.bash_profile文件里的PATH中添加相应路径。

[mysql@redhat5-db-1 ~]$ cp -pr /opt/software/mysql-5.1.45/support-files /opt/mysql
[mysql@redhat5-db-1 ~]$ chmod u+x /opt/mysql/support-files/mysql.server
[mysql@redhat5-db-1 ~]$ which mysql.server
/opt/mysql/support-files/mysql.server
[mysql@redhat5-db-1 ~]$ mysql.server stop
Shutting down MySQL.100331 18:58:49 mysqld_safe mysqld from pid file /data/mysql/redhat5-db-1.pid ended
                                                          [  OK  ]

以上是“Linux下如何安装配置源代码版本的MySQL”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


名称栏目:Linux下如何安装配置源代码版本的MySQL
网页链接:http://bjjierui.cn/article/jdjdpp.html

其他资讯