Home >Database >Mysql Tutorial >linux下MYSQL常见两个错误的解决办法_MySQL

linux下MYSQL常见两个错误的解决办法_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:55:071331browse

问题1:登录mysql的错误

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

解决方法:

1)默认的mysql.sock文件是在/tmp目录下。
2)我们建立一个软连接,ln -s /tmp/mysql.sock  /var/lib/mysql/mysql.sock

问题2:Timeout error occurred trying to start MySQL Daemon.
#/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

Statement:
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