Home > Database > Mysql Tutorial > Timeout error occurred trying to startMySQL Daemon_MySQL

Timeout error occurred trying to startMySQL Daemon_MySQL

WBOY
Release: 2016-06-01 13:57:24
Original
1202 people have browsed it

    #/etc/init.d/mysqld restart
stopping mysql     [ok]
Timeout error occurred trying to start MySQL Daemon.  [failure] 
但是这个时候mysql实际上已经起动了,因为用netstat -ln命令去看3306端口已经起动.使用mysql -u root -p password也能连接到数据库.

解决方法:
修改/etc/init.d/mysqld.
在mysql里创建dameon用户,然后再修改/etc/init.d/mysqld.
具体操作如下:
我们不妨先看看/etc/init.d/mysqld起动脚本是如何工作的,注意下面的一段
# If you've removed anonymous users, this line must be changed to
        # use a user that is allowed to ping mysqld.
        ping="/usr/bin/mysqladmin -uUNKNOWN_MYSQL_USER ping"
        # Spin for a maximum of ten seconds waiting for the server to come up
        if [ $ret -eq 0 ]; then
            for x in 1 2 3 4 5 6 7 8 9 10; do
            if [ -n "`$ping 2> /dev/null`" ]; then
                    break;
            else
                    sleep 1;
            fi
            done
            if !([ -n "`$ping 2> /dev/null`" ]); then
                    echo "Timeout error occurred trying to start MySQL
Daemon."                    action $"Starting $prog: " /bin/false
            else
                    action $"Starting $prog: " /bin/true
            fi
        else
            action $"Starting $prog: " /bin/false
        fi
        [ $ret -eq 0 ] && touch /var/lock/subsys/mysqld
        return $ret 
 
    我们看到,脚本判断mysql是否起动,使用的是mysqladmin ping命令. http://webjx.com
    而这个命令想要正确执行是需要能够登录mysql的.现在一些默认帐号已经删除,而且其它帐号已经设置了密码(默认没有设置密码).于是它没有办法连接到mysql. http://webjx.com
   于是我用了下面的办法解决.
   a)建立一个帐号,不设置密码,不给任何权限.
   b)修改/etc/init.d/mysqld
   下面我给出具体操作
   #mysql -u root -p passwd
   mysql>GRANT select ON test.* TO daemon@localhost
   mysql>revoke select on test.* from daemon@localhost 
   vi打开/etc/init.d/mysqld
   把下面这行
   ping="/usr/bin/mysqladmin -uUNKNOWN_MYSQL_USER ping" 

   修改为
   ping="/usr/bin/mysqladmin -udaemon ping" 

  保存,退出.
  重新起动mysql
  #/etc/init.d/mysqld restart
  Stopping MySQL:                                            [  OK  ]
  Starting MySQL:                                            [  OK  ]
 
  这样就可以了.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template