Can't connect to MySQL server on 'db' ([Errno 111] Connection refused)

walle docker运行报错

walle-python | Migration walle
walle-python | ----------------
walle-python | Traceback (most recent call last):
walle-python |   File "/usr/local/bin/flask", line 10, in <module>
walle-python |     sys.exit(main())
walle-python |   File "/usr/local/lib/python2.7/site-packages/flask/cli.py", line 894, in main
walle-python |     cli.main(args=args, prog_name=name)
walle-python |   File "/usr/local/lib/python2.7/site-packages/flask/cli.py", line 557, in main
walle-python |     return super(FlaskGroup, self).main(*args, **kwargs)
walle-python |   File "/usr/local/lib/python2.7/site-packages/click/core.py", line 717, in main
walle-python |     rv = self.invoke(ctx)
walle-python |   File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
walle-python |     return _process_result(sub_ctx.command.invoke(sub_ctx))
walle-python |   File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
walle-python |     return _process_result(sub_ctx.command.invoke(sub_ctx))
walle-python |   File "/usr/local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
walle-python |     return ctx.invoke(self.callback, **ctx.params)
walle-python |   File "/usr/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
walle-python |     return callback(*args, **kwargs)
walle-python |   File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
walle-python |     return f(get_current_context(), *args, **kwargs)
walle-python |   File "/usr/local/lib/python2.7/site-packages/flask/cli.py", line 412, in decorator
walle-python |     return __ctx.invoke(f, *args, **kwargs)
walle-python |   File "/usr/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
walle-python |     return callback(*args, **kwargs)
walle-python |   File "/usr/local/lib/python2.7/site-packages/flask_migrate/cli.py", line 134, in upgrade
walle-python |     _upgrade(directory, revision, sql, tag, x_arg)
walle-python |   File "/usr/local/lib/python2.7/site-packages/flask_migrate/__init__.py", line 95, in wrapped
walle-python |     f(*args, **kwargs)
walle-python |   File "/usr/local/lib/python2.7/site-packages/flask_migrate/__init__.py", line 280, in upgrade
walle-python |     command.upgrade(config, revision, sql=sql, tag=tag)
walle-python |   File "/usr/local/lib/python2.7/site-packages/alembic/command.py", line 276, in upgrade
walle-python |     script.run_env()
walle-python |   File "/usr/local/lib/python2.7/site-packages/alembic/script/base.py", line 475, in run_env
walle-python |     util.load_python_file(self.dir, "env.py")
walle-python |   File "/usr/local/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 90, in load_python_file
walle-python |     module = load_module_py(module_id, path)
walle-python |   File "/usr/local/lib/python2.7/site-packages/alembic/util/compat.py", line 216, in load_module_py
walle-python |     mod = imp.load_source(module_id, path, fp)
walle-python |   File "migrations/env.py", line 90, in <module>
walle-python |     run_migrations_online()
walle-python |   File "migrations/env.py", line 72, in run_migrations_online
walle-python |     connection = engine.connect()
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2102, in connect
walle-python |     return self._connection_cls(self, **kwargs)
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 90, in __init__
walle-python |     if connection is not None else engine.raw_connection()
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2188, in raw_connection
walle-python |     self.pool.unique_connection, _connection)
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2162, in _wrap_pool_connect
walle-python |     e, dialect, self)
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1476, in _handle_dbapi_exception_noconnection
walle-python |     exc_info
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 265, in raise_from_cause
walle-python |     reraise(type(exception), exception, tb=exc_tb, cause=cause)
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2158, in _wrap_pool_connect
walle-python |     return fn()
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 342, in unique_connection
walle-python |     return _ConnectionFairy._checkout(self)
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 788, in _checkout
walle-python |     fairy = _ConnectionRecord.checkout(pool)
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 529, in checkout
walle-python |     rec = pool._do_get()
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 1284, in _do_get
walle-python |     return self._create_connection()
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 347, in _create_connection
walle-python |     return _ConnectionRecord(self)
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 474, in __init__
walle-python |     self.__connect(first_connect_check=True)
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 671, in __connect
walle-python |     connection = pool._invoke_creator(self)
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 106, in connect
walle-python |     return dialect.connect(*cargs, **cparams)
walle-python |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 412, in connect
walle-python |     return self.dbapi.connect(*cargs, **cparams)
walle-python |   File "/usr/local/lib/python2.7/site-packages/pymysql/__init__.py", line 94, in Connect
walle-python |     return Connection(*args, **kwargs)
walle-python |   File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 325, in __init__
walle-python |     self.connect()
walle-python |   File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 630, in connect
walle-python |     raise exc
walle-python | sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'db' ([Errno 111] Connection refused)") (Background on this error at: http://sqlalche.me/e/e3q8)
walle-python | Migration:                 [ fail ]
walle-python | Server initialized for gevent.

然后
Can't connect to MySQL server on 'db' ([Errno 111] Connection refused)
我这样操作也没有用

上一篇:PHP连接MySQL数据库


下一篇:Linux Socket编程(不限Linux)