xpleaf / Blog_mini

An Open Source Blog System that developed with Flask.
Other
982 stars 469 forks source link

初始化Blog_mini系统默认数据时候报错 #29

Closed heycyril closed 6 years ago

heycyril commented 6 years ago

初始化Blog_mini系统默认数据时候报错, mysql是docker安装的,端口为13333,数据库可以远程连接,应该没问题, 我不知道是我的端口不对吗,还是什么问题,需要在哪个配置文件中修改这些,谢谢 我改用本地直接安装mysql可以,但是好像运行成功之后库里面没表啊,难道是我姿势不对?

除了这个问题之外,我还想就是在写文章的时候插入图片能直接粘贴吗,要不然有时候像云笔记中的文章想直接复制发表,图片很不方便

(venv) [root@123 Blog_mini]# python manage.py deploy product Traceback (most recent call last): File "manage.py", line 78, in manager.run() File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/flask_script/init.py", line 412, in run result = self.handle(sys.argv[0], sys.argv[1:]) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/flask_script/init.py", line 383, in handle res = handle(*args, config) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/flask_script/commands.py", line 216, in call return self.run(args, kwargs) File "manage.py", line 43, in deploy upgrade() File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/flask_migrate/init.py", line 233, in upgrade command.upgrade(config, revision, sql=sql, tag=tag) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/alembic/command.py", line 254, in upgrade script.run_env() File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/alembic/script/base.py", line 427, in run_env util.load_python_file(self.dir, 'env.py') File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 81, in load_python_file module = load_module_py(module_id, path) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/alembic/util/compat.py", line 141, in load_module_py mod = imp.load_source(module_id, path, fp) File "migrations/env.py", line 87, in run_migrations_online() File "migrations/env.py", line 72, in run_migrations_online connection = engine.connect() File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2018, in connect return self._connection_cls(self, kwargs) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 72, in init if connection is not None else engine.raw_connection() File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2104, in raw_connection self.pool.unique_connection, _connection) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2078, in _wrap_pool_connect e, dialect, self) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1405, in _handle_dbapi_exception_noconnection exc_info File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2074, in _wrap_pool_connect return fn() File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/pool.py", line 318, in unique_connection return _ConnectionFairy._checkout(self) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/pool.py", line 713, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/pool.py", line 480, in checkout rec = pool._do_get() File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/pool.py", line 1151, in _do_get return self._create_connection() File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/pool.py", line 323, in _create_connection return _ConnectionRecord(self) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/pool.py", line 449, in init self.connection = self.connect() File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/pool.py", line 607, in connect connection = self.__pool._invoke_creator(self) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 97, in connect return dialect.connect(cargs, cparams) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 385, in connect return self.dbapi.connect(*cargs, cparams) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/MySQLdb/init.py", line 81, in Connect return Connection(*args, *kwargs) File "/usr/local/python_blog/Blog_mini/venv/lib/python2.7/site-packages/MySQLdb/connections.py", line 193, in init super(Connection, self).init(args, kwargs2) sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2003, "Can't connect to MySQL server on '127.0.0.1' (111)") (venv) [root@123 Blog_mini]#

xpleaf commented 6 years ago

从你这报错看就是数据库的连接有问题了,使用mysql时需要设定一个环境变量的,比如:

export DATABASE_URL=mysql://root:123456@127.0.0.1/blog_mini

这里默认指定的端口是3306。 另外,没有图片服务器,所以确实需要第三方的图片链接,在后续版本中会改进这一点。

heycyril commented 6 years ago

那我指定13333端口应该怎么指定呢

heycyril commented 6 years ago

可以直接在文件里面定义成这样吗,直接修改配置文件就行,不用再声明变量 conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='123',db='girl')

heycyril commented 6 years ago

已解决 export DATABASE_URL=mysql://root:123456@172.16.75.128:33333/blog_mini

heycyril commented 6 years ago

请问在编辑文章的时候插入图片直接粘贴进去,不同再链接插入,这个功能好实现吗

xpleaf commented 6 years ago

实现应该不会太难,包括粘贴之后可以实现上传的功能,但这个需要前端插件的支持,具体我也没有研究过,你可以研究下。

heycyril commented 6 years ago

好,闲了我看看,