比如默认的datadir=/var/lib/mysql,我想改为datadir=/home/mysql我把/etc/my.cnf中的datadir改了,再起mysql起不来了。

解决方案 »

  1.   

    cp -rf /var/lib/mysql/ /home
    启动MySQL还是起不来
    报错:
         Timeout error occurred trying to start MySQL Daemon.
    Starting MySQL:  [FAILED]
      

  2.   

    ll /home/mysql
    看一下内容。
      

  3.   

    [root@localhost mysql]# ll /home/mysql/
    total 20528
    -rw-r----- 1 mysql mysql 10485760 2009-12-08 12:38 ibdata1
    -rw-r----- 1 mysql mysql  5242880 2009-12-08 12:38 ib_logfile0
    -rw-r----- 1 mysql mysql  5242880 2009-12-08 12:38 ib_logfile1
    drwx------ 2 mysql mysql     4096 2009-12-08 12:38 mysql
    drwx------ 2 mysql mysql     4096 2009-12-08 12:38 test
      

  4.   

    贴一下你的 my.cnf 
    和你启动mysql服务用的命令。
      

  5.   

    091208 13:09:14  mysqld started
    091208 13:09:14  InnoDB: Operating system error number 13 in a file operation.
    InnoDB: The error means mysqld does not have the access rights to
    InnoDB: the directory.
    InnoDB: File name ./ibdata1
    InnoDB: File operation call: 'open'.
    InnoDB: Cannot continue operation.
    091208 13:09:14  mysqld ended
    这是log里打印的信息
      

  6.   

    [mysqld]
    #datadir=/var/lib/mysql
    datadir=/home/mysql
    #socket=/var/lib/mysql/mysql.sock
    socket=/home/mysql/mysql.sock
    user=mysql
    # Default to using old password format for compatibility with mysql 3.x
    # clients (those using the mysqlclient10 compatibility package).
    old_passwords=1#max_allowed_packet = 16M
    #table_cache = 512
    #sort_buffer_size = 2M
    #read_buffer_size = 2M
    #read_rnd_buffer_size = 8M
    #myisam_sort_buffer_size = 64M
    #thread_cache_size = 8
    #query_cache_size = 32M
    #tmp_table_size=64M
    #max_heap_table_size=64M[mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
      

  7.   

    The error means mysqld does not have the access rights to the directory.比较一下权限!-rw-r----- 1 mysql mysql 10485760 2009-12-08 12:38 ibdata1
    -rw-r----- 1 mysql mysql  5242880 2009-12-08 12:38 ib_logfile0
    -rw-r----- 1 mysql mysql  5242880 2009-12-08 12:38 ib_logfile1检查一下原目录中的权限,或者直接给成 777
      

  8.   

    chmod -R 777 /home/mysql了,
    还是不行啊
      

  9.   


    ll /home/mysql
    ll 你原来的目录