110316 22:28:41 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
110316 22:28:41 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
110316 22:28:41 [ERROR] Aborting110316 22:28:41 [Note] mysqld: Shutdown complete
我之前修改了my.cnf,增加了innodb部分,然后重启linux系统,再启动mysqld时出现如上错误,查询了网上的一些类似问题,说是权限问题,我执行了
chown -R mysql:mysql /var/lib/mysql
并将这个目录的权限更改为755
后均无效,我没有sulinux.my.cnf修改如下:
[client]
port            = 3306
socket          =/tmp/mysql.sock
#socket         = /var/run/mysqld/mysqld.sock# Here is entries for some specific programs
# The following values assume you have at least 32M ram# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket          =/tmp/mysql.sock
#socket         = /var/run/mysqld/mysqld.sock
nice            = 0[mysqld]
#
# * Basic Settings
##
# * IMPORTANT
#   If you make changes to these settings and your system uses apparmor, you may
#   also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
#
user            = mysql
socket          =/tmp/mysql.sock
#socket         = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
skip-external-locking
#skip_grant_tables
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            =10.10.11.166    //127.0.0.1  the ip of secure# * Fine Tuning
#
key_buffer              = 16M
max_allowed_packet      = 50M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 16M
general_log_file        = /var/log/mysql/mysql.log
general_log             = 1log_error                = /var/log/mysql/error.log# Here you can see queries with especially long duration
#log_slow_queries       = /var/log/mysql/mysql-slow.log
#slow_query_log =/var/log/mysql/mysql-slow.log
long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
log_bin                 = /var/log/mysql/mysql-bin.log
#log                     =/var/log/mysql/mysql.log
expire_logs_days        = 10
max_binlog_size         = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!//如下部分为我添加的
#innodb_additional_mem_pool_size=16M
#innodb_data_file_path=
#innodb_data_home_dir=var/lib/mysql
#innodb_file_to_threads=4
#innodb_force_recovery=1
#innodb_flush_log_trx_commit=2
#innodb_log_buffer_size=8M
#innodb_log_file_size=256M
#innodb_log_files_in_group=3
#innodb_log_group_home_dir=/var/log/mysql/innodb.log
#innodb_max_dirty_pages_pct=90
#innodb_lock_wait_timeout=120

解决方案 »

  1.   

    先检查一下这个目录的权限 /var/lib/mysql/
      

  2.   

    root@localhost:/home/andy# ls -ld  /var/lib/mysql
    drwx------ 15 755 mysql 4096 2011-03-16 22:28 /var/lib/mysql
    mysq组对此有权限啊
      

  3.   

    我用mysqld_safe --user=mysql 启动后,mysql可以启动,但是出现了个问题,mysql启动采用了默认的配置,basedir和datadir都不是原先的那个目录了,启动时根本没有读my.cnf这个文件
    mysqld_safe --user=mysqlps -ef |grep msyqlroot      5051 30794  0 15:24 pts/3    00:00:00 grep --color=auto mysql
    mysql    29955 29935  0 14:24 ?        00:00:01 /usr/local/libexec/mysqld --basedir=/usr/local --datadir=/usr/local/var --user=mysql --pid-file=/usr/local/var/localhost.pid --skip-external-locking
    如果我是用入校指令启动
    root@localhost:/var/lib/mysql# mysqld_safe --defaults-file=/etc/mysql/my.cnf
    nohup: ignoring input and redirecting stderr to stdout
    Starting mysqld daemon with databases from /var/lib/mysql
    STOPPING server from pid file /var/lib/mysql/localhost.pid
    110317 15:12:57  mysqld ended/var/lib/mysql下没有localhost.pid文件,可之前其实是有的,这是咋么回事啊?
      

  4.   

    chown 不是改权限的命令,chmod才是赋予权限的命令,楼主搞混了吧!
      

  5.   

    检查你到底是用什么账号在运行MYSQL的就知道了,应该不是用MYSQL这个用户。