器量大者,福泽必厚
全部博文(587)
分类: Mysql/postgreSQL
2009-09-09 12:16:42
Unix上在哪里指定选项? 在Unix上,mysqld从下列文件,如果它们存在的话。以下列的顺序读取选项:
·
/etc/my.cnf
全局选项。
·
$MYSQL_HOME/my.cnf
服务器专用选项。
·
defaults-extra-file
--defaults-extra-file选项指定的文件。
·
~/.my.cnf
用户专用选项。
运行级别是越来越高:
我的测试环境如下:
[root@localhost lib]# lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5 (Tikanga)
Release: 5
Codename: Tikanga
[root@localhost lib]# cat /etc/issue
Red Hat Enterprise Linux Server release 5 (Tikanga)
Kernel \r on an \m
[root@localhost lib]# uname -r
2.6.18-8.el5xen
我的mysql为:
[root@localhost mysql]# ls
bin docs lib mysql-test sql-bench
configure EXCEPTIONS-CLIENT man README support-files
COPYING include my.cnf scripts tests
data INSTALL-BINARY my.cnf.bak share
[root@localhost mysql]# pwd -P
/usr/local/mysql-5.0.83-linux-i686
[root@localhost mysql]# pwd
/usr/local/mysql
[root@localhost mysql]#
显然我的mysql为mysql-5.0.83,mysql为mysql-5.0.83的一个链接。
1:我在/etc下方了个my.cnf文件, 内容如下:
[root@localhost mysql]# cat /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
innodb_data_file_path = ibdata1:30M:autoextend
[mysql.server]
user=mysql
basedir=/usr/local/mysql
[mysqld_safe]
log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid
显然是正确的。而/usr/local/mysql下没有my.cnf文件。
我的mysql是可以启动的。
如下:
[root@localhost etc]# /usr/local/mysql/bin/mysqld_safe --user=mysql &
[1] 3997
[root@localhost etc]# Starting mysqld daemon with databases from /usr/local/mysql/data
[root@localhost etc]# netstat -antl | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
显然mysql已经启动。
2:当/etc/my.cnf和/usr/local/mysql/my.cnf都存在时。而/etc/my.cnf是正确的,而/usr/local/mysql/my.cnf是错误的。 /usr/local/mysql/my.cnf内容如下:
[root@localhost mysql]# /usr/local/mysql/bin/mysqladmin shutdown
STOPPING server from pid file /usr/local/mysql/data/mysqld.pid
090909 12:10:15 mysqld ended
[1]+ Done /usr/local/mysql/bin/mysqld_safe --user=mysql (wd: /etc)
(wd now: /usr/local/mysql)
[root@localhost mysql]# cat my.cnf
[mysqld]
datadir=/var/lib
socket=/tmp/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
innodb_data_file_path = ibdata1:30M:autoextend
[mysql.server]
user=mysql
basedir=/var/lib/mysql
[mysqld_safe]
log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid
启动mysql如下:
[root@localhost mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql &
[1] 4056
[root@localhost mysql]# Starting mysqld daemon with databases from /var/lib
STOPPING server from pid file /usr/local/mysql/data/mysqld.pid
090909 12:10:46 mysqld ended
显然,mysqld是启动不了的 。
就是说同时有/etc/my.cnf和/usr/local/mysql/my.cnf是优先加载后者!
后面的两项就不测试了。 测试方法是一样的!