1、安装 5.1 GA

创建组和用户:

[root@mysqldb2 ~]# groupadd mysql

[root@mysqldb2 ~]# useradd -g mysql mysql

解压缩包:

[root@mysqldb2 ~]$ cd /data/software/

[root@mysqldb2 software]$ tar xvfz mysql-5.1.51.tar.gz

[root@mysqldb2 software]$ cd mysql-5.1.51

进入mysql安装包目录,执行configure并加载适当参数:

[root@mysqldb2 mysql-5.1.51]# ./configure –prefix=/usr/local/mysql/ –with-server-suffix=-ITE –enable-assembler –enable-local-infile –enable-thread-safe-client –with-big-tables –with-charset=utf8 –with-extra-charsets=all –with-ssl –with-embedded-server –with-pthread –with-mysqld-user=mysql –with-mysqld-ldflags=-all-static –with-client-ldflags=-all-static –with-plugins=all –with-unix-socket-path=/tmp/mysql5-1.sock

提示:configure支持的选项非常多,详细的参数及说明建议参考官方文档,也可以通过./configure –help查看,这里仅列出常用及推荐使用的选项。

–prefix=PREFIX:指定程序安装路径;–enable-assembler:使用汇编模式;–enable-local-infile:启用对LOAD DATA LOCAL INFILE语法的支持(默认不支持);–enable-profiling:Build a version with query profiling code (req.community-features)–enable-thread-safe-client:使用编译客户端;–with-big-tables:启用32位平台对4G大表的支持;–with-charset=CHARSET:指定字符集;–with-collation=:默认collation;–with-extra-charsets=CHARSET,CHARSET,…:指定附加的字符集;–with-fast-mutexes:Compile with fast mutexes–with-readline:–with-ssl:启用SSL的支持;–with-server-suffix=:添加字符串到版本信息;–with-embedded-server:编译embedded-server;–with-pthread:强制使用pthread类库;–with-mysqld-user=:指定mysqld守护进程的用户;–with-mysqld-ldflags=:静态编译MySQL服务器端;–with-client-ldflags=:静态编译MySQL客户端;–with-plugins=PLUGIN,PLUGIN,…:MySQL服务器端支持的组件(默认为空),可选值较多:partition:MySQL Partitioning Support;daemon_example:This is an example plugin daemon;ftexample:Simple full-text parser plugin;archive:Archive Storage Engine;blackhole:Basic Write-only Read-never tables;csv:Stores tables in text CSV format,强制安装;example:Example for Storage Engines for developers;federated:Connects to tables on remote MySQL servers;heap:Volatile memory based tables,强制安装;ibmdb2i:IBM DB2 for i Storage Engine;innobase:Transactional Tables using InnoDB;innodb_plugin:Transactional Tables using InnoDB;myisam:Traditional non-transactional MySQL tables,强制安装;myisammrg:Merge multiple MySQL tables into one,强制安装;ndbcluster:High Availability Clustered tables;–with-plugin-PLUGIN:强制指定的插件链接至MySQL服务器;–with-zlib-dir=:向MySQL提供一个自定义的压缩类库地址;–without-server:仅安装MySQL客户端;–without-query-cache:不要编译查询缓存;–without-geometry:不要编译geometry-related部分;–without-debug:编译为产品版,放弃debugging代码;–without-ndb-debug:禁用special ndb debug特性;

提示:执行Configure时如果报bin/rm: cannot remove `libtoolt’: No such file or directory错误,可按照下列步骤解决:

1、确认libtool是否已经安装,如果没有安装的话,则先安装libtool

# rpm -qa | grep libtool

# yum -y install libtool

2、分别执行以下三条命令:

# autoreconf –force –install

# libtoolize –automake –force

# automake –force –add-missing

再重新编译安装,问题解决!

继续执行编译:

[root@mysqldb2 mysql-5.1.51]# make > /home/jss/mysql_setuplogs_make.log 2>&1

[root@mysqldb2 mysql-5.1.51]# make install > /home/jss/mysql_setuplogs_makeinstall.log 2>&1

修改相关路径权限:

[root@mysqldb2 mysql-5.1.51]# cd /usr/local/

[root@mysqldb2 local]# chown -R mysql:mysql mysql

复制程序文件到/usr/bin目录下,方便调用:

[root@mysqldb2 local]# cp /usr/local/mysql/bin/mysql* /usr/bin/

至此,MySQL数据库安装完全,此时已可使用mysql命令行工具连接其它MySQL数据库了。

2. 创建

创建目录并修改权限:

[root@mysqldb2 local]# cd /data

[root@mysqldb2 data]# mkdir mysqldata

[root@mysqldb2 data]# cd mysqldata

[root@mysqldb2 mysqldata]# mkdir 3306

[root@mysqldb2 mysqldata]# cd 3306

[root@mysqldb2 3306]# mkdir data binlog tmp innodb_ts innodb_log

[root@mysqldb2 3306]# cd /data

[root@mysqldb2 data]# chown -R mysql:mysql mysqldata

创建数据库:

[root@mysqldb2 local]# cd mysql/

[root@mysqldb2 mysql]# bin/mysql_install_db –user=mysql –datadir=/data/mysqldata/3306/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 mysqldb2 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 with the /usr/local/mysql/bin/mysqlbug script!