0

I am trying to run my Django server but I get error (2003, "Can't connect to MySQL server on '127.0.0.1' (61)"). I have found information in this topic that the problem can by caused by MySQL port. I had checked it using SHOW GLOBAL VARIABLES LIKE 'PORT'; and I got value 0. It seems to me that it may be a reason. I have checked in my.cnf default port but everything seems to look good port = 3306. I wonder what should I do now? Thanks in advance.

SOLUTION: I commented line skip-networking in my.cnf file.

1 Answers1

-1

Add bind-address = 127.0.0.1 to your my.cnf under [mysqld]. Then restart the MySQL server. That will let it listen to the local IP address.

bind-address = 0.0.0.0 will let it listen to all IP addresses (not recommended for production, but useful for debugging).

cwallenpoole
  • 79,954
  • 26
  • 128
  • 166
  • Can I add `bind-address = 127.0.0.1` at the end of the file? How can I restart MySQL? –  Jun 13 '17 at 16:44
  • I believe `XAMPP` has a control panel which would let you restart MySQL. Put it under `[mysqld]`. – cwallenpoole Jun 13 '17 at 16:46
  • I have done everything as you have written and `SHOW GLOBAL VARIABLES LIKE 'PORT'` still returns `0` and server - (2003, "Can't connect to MySQL server on '127.0.0.1' (61)"). –  Jun 13 '17 at 16:49
  • Can you use `localhost` as a setting in Django and see what happens there? – cwallenpoole Jun 15 '17 at 16:18