Page 1 of 1

Подключение к MySQL

Posted: Sat Dec 14, 2013 9:58 am
by ifelse
Уже надоело воевать с MySQL.
Отвалилось подключение по localhost

Code: Select all

[root@classic ~]# mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
но работает по 127.0.0.1:

Code: Select all

[root@classic ~]# mysql -u root -h 127.0.0.1 -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 122
Server version: 5.5.35 MySQL Community Server (GPL) by Remi

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
/etc/my.cnf:

Code: Select all

[mysqld]
datadir=/var/lib/mysql
socket=/tmp/mysql.sock
user=mysql
symbolic-links=0
max_connections=200
max_user_connections=0
wait_timeout=30
interactive_timeout=50
long_query_time=5
#log-queries-not-using-indexes
#log-slow-queries=/var/log/mysql/log-slow-queries.log

#innodb_use_native_aio = 0
innodb_file_per_table


[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
Обратите внимание, что сокет отличается от сокета в ошибке при подключении.

Далее смотрим что у нас в ps:

Code: Select all

[root@classic ~]# ps ax | grep mysql
28176 pts/0    S      0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/tmp/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql

28455 pts/0    Sl     0:10 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/tmp/mysql.sock

29253 pts/0    S+     0:00 grep mysql
С mysqldump поведение аналогичное. Из-за данной проблемы создать базу данных в панеле невозможно (предполагаю, что панель коннектится по localhost).

Re: Подключение к MySQL

Posted: Wed Dec 18, 2013 9:33 pm
by skid
Попробуйте заменить путь для сокета в конфиге my.cnf на
socket=/var/lib/mysql/mysql.sock