python - 关闭终端后未退出 "Connection refused"错误。 Django 1.8

标签 python mysql django terminal

在我没有退出和停止服务器的情况下关闭终端窗口后,没有任何原因,下次我运行任何命令,如 python manage.py migrate/runserver/makemigrations 我得到以下回溯。我真的不明白是什么现在错了吗?

编辑:同样在'mysql'命令中进入它的界面'无法通过套接字'/tmp/mysql.sock'(2)'连接到本地MySQL服务器

EDIT2:我想这可能是由 MAMP 引起的,它也安装在我的 MAC 上

EDIT3:在我删除 MAMP 之后。不确定是否直接连接。也无法进入mysql shell。

django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")

EDIT4!!:
我在 mac 上使用终端,所以我应用了这个命令 sudo /usr/local/mysql/support-files/mysql.server start 然后回来了

ERROR! MySQL server process #1180 is not running! Starting MySQL..... ......... ......... 

尝试启动服务器后

ERROR! The server quit without updating PID file (/usr/local/mysql/data/MacBook-Air-Vitalij.local.pid).

重启命令:

ERROR! MySQL server PID file could not be found!

EDIT5:根据答案的建议,我尝试更改 max_connections,但没有成功:

mysql --help | grep "Default options" -A 1 
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf 

我尝试了所有路径,但它不存在。而且我无法手动找到此文件,我发现 MySQL for Mac 中没有 my.cnf。还尝试删除 MySQL 并重新安装它 - 也没有帮助。

open -a Finder etc/mysql/my.cnf
The file /Users/TheKotik/djboy/etc/mysql/my.cnf does not exist.

enter image description here enter image description here

最佳答案

考虑增加max_connections 并重启mysql。

sudo /usr/local/mysql/support-files/mysql.server restart

由于某种原因,关闭终端时连接没有正确关闭。增加 max_connections 不会完全解决它,但挂起的连接最终会超时。

关于python - 关闭终端后未退出 "Connection refused"错误。 Django 1.8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40507393/

相关文章:

Django 将对象从 View 传递到下一个进行处理

python - Scrapy 抑制处理的错误

python - Python 中有模块级变量吗?

python - 通过命令行python批量上传视频到youtube

python - 在 Django 中创建 url 的正确方法

python - Django Rest_framework.views 如何跳过数据库连接以获得简单的 REST API

python - 对具有共享端节点的边进行采样

mysql - 获取 MySQL 中的当前用户,无需主机名

php - 数据库输出未显示。获取 else 语句

php - 搜索键分页问题,​​当单击任何链接或搜索另一个键时,应该使用 unset 来销毁 session