when connecting to mysql database in Django ,I get the error.
I'm sure mysql server is running.
/var/run/mysqld/mysqld.sock doesn't exist.
When I run $ find / -name *.sock -type s
, I only get /tmp/mysql.sock and some other irrelevant output.
I added socket = /tmp/mysql.sock
to /etc/my.cnf. And then restared mysql, exited django shell, and connected to mysql database. I still got the same error.
I searched a lot, but I still don't know how to do.
Any help is greate. Thanks in advance.
Well, I just tried some ways. And it works.
I did as follows.
- Add
socket = /tmp/mysql.sock
.Restart the mysql server.
ln -s /tmp/mysql.sock /var/lib/mysqld/mysqld.sock
I met an another problem today. I can't login to mysql.
I'm newbie to mysql. So I guess mysql server and client use the same socket to communicate.
I add socket = /var/mysqld/mysqld.sock
to [mysqld] [client] block in my.cnf and it wokrs.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…