发表时间:2008-08-07
最后修改:2009-09-23
原文地址:
http://hi.baidu.com/rambochow/blog/item/bc7a6e90798d248ea877a469.html
自定义安装
MySQL
(mysql-max-5.0.27-linux-i686-glibc23)
2007-10-11
下午
03:56
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> tar -xzvf mysql-max-5.0.27-linux-i686-glibc23.tar.gz
shell> ln -s mysql-max-5.0.27-linux-i686-glibc23 mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &
1.
安装版本的选择:
这里使用较新的mysql5.0
安装。注意 mysql
官方不建议使用Tarball
(Source Code
)方式安装,
所以我们采用由mysql
自己编译好的binary
方式来安装,简单。当然,mysql
还给Redhat
企业版等提供了Rpm
的安装包。
2.
下载 (http://mirror.x10.com/mirror/mysql/Downloads/MySQL-5.0/mysql-max-5.0.27-linux-i686-glibc23.tar.gz
)
这里要注意了,由于glibc
的版本不同需要下载相应的tar.gz
,看看自己的glibc
版本
# rpm -qa | grep glibc
glibc-common-2.3.2-11.9
glibc-2.3.2-11.9
glibc-kernheaders-2.4-8.10
glibc-devel-2.3.2-11.9
我的机器上是2.3.2
,所以我下载了mysql-max-5.0.27-linux-i686-glibc23.tar.gz
保存到/home/xqiang
(选择max
,免得有什么功能没有安装,哈哈)
3.
建立mysql
需要的用户和组
# groupadd mysql
# useradd -g mysql mysql
4.
解压缩
# cd /usr/local
# tar -xzvf /home/xqiang/mysql-max-5.0.27-linux-i686-glibc23.tar.gz
# ln -s /usr/local/mysql-max-5.0.27-linux-i686-glibc23 mysql
5.
生成系统数据库
# cd /usr/local/mysql (
如果不是在这个目录下操作则会出现《问题一》)
# scripts/mysql_install_db --user=mysql (
这里会出现《问题二》,不用理它)
6.
修改mysql
目录权限
# chown -R root /usr/local/mysql
# chgrp -R mysql /usr/local/mysql
(以上两句可以直接#chown -R root:mysql /usr/local/mysql
)
# chown -R mysql /usr/local/data
操作mysql
数据库的用户是mysql
所以要拥有数据库目录的所有权
7.
启动mysql
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
注意: 执行完这个命令后,会在/tmp
产生一个mysql.sock
的文件
这是访问mysql
必须的!
8.
将配置文件拷贝到/etc
# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
9.
设置MYSQL
的中文问题(
这一步在创建用户数据库之前完成,并要重启MYSQL)
# vi /etc/my.cnf
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
default-character-set=gb2312 //
添加的内容
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8 //
添加的内容
另外,mysql
目录下有一个安装文件 INSTALL-BINARY
,介绍了安装的步骤!
其他设定:
关于mysql
的一些配置项可以在/etc/my.cnf
中更改!
设置mysql
执行程序的path:
# vi /etc/profile
添加:
PATH=$PATH:/usr/local/mysql/bin
export PATH
设置mysql
启动
# /usr/local/mysql/bin/mysqld_safe --user=mysql & (
启动MySQL,
但不能停止)
使用mysql
提供的脚本
# cp /usr/local/mysql/support-files/mysql.server /usr/local/mysql/bin
# mysql.server start
启动mysql
# mysql.server stop
停止mysql
随系统自动启动
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
# chkconfig --add mysql
修改mysql
超级用户root
的密码
# mysqladmin -u root -p password '123456'
Enter password:
回车就行 ,默认的密码为空
最好完成这一步:
# ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
# ln -s /usr/local/mysql/include/mysql /usr/include/mysql
问题一:
my_print_defaults:
command not found
Could not find help file 'fill_help_tables.sql' in ./support-files or inside ..
问题二:
Installing all prepared tables
Fill help tables
HELP FILES CAN NOT COMPLETE INSTALL
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:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
See the manual for more instructions.
NOTE: If you are upgrading from a MySQL <= 3.22.10
you should run
the ./bin/mysql_fix_privilege_tables. Otherwise you will not be
able to use the new GRANT command!
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the ./bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com