Unable to start seahub.sh with mysql

Hello,
I’ve installed seafile on a Debian 8 machine. I’ve installed seafile with mysql, without any issue.
Then, I’ve launched seafiile.sh, successfully.
But when I want to launch seahub.sh with fastcgi, it returns

LC_ALL is not set in ENV, set to en_US.UTF-8
Starting seahub (fastcgi) at 127.0.0.1:8000 ...
Traceback (most recent call last):
  File "/seafile/www/seafile-pro-server-6.1.1/seahub/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/seafile/www/seafile-pro-server-6.1.1/seahub/thirdpart/Django-1.8.18-py2.7.egg/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/seafile/www/seafile-pro-server-6.1.1/seahub/thirdpart/Django-1.8.18-py2.7.egg/django/core/management/__init__.py", line 303, in execute
    settings.INSTALLED_APPS
  File "/seafile/www/seafile-pro-server-6.1.1/seahub/thirdpart/Django-1.8.18-py2.7.egg/django/conf/__init__.py", line 48, in __getattr__
    self._setup(name)
  File "/seafile/www/seafile-pro-server-6.1.1/seahub/thirdpart/Django-1.8.18-py2.7.egg/django/conf/__init__.py", line 44, in _setup
    self._wrapped = Settings(settings_module)
  File "/seafile/www/seafile-pro-server-6.1.1/seahub/thirdpart/Django-1.8.18-py2.7.egg/django/conf/__init__.py", line 92, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/importlib-1.0.2-py2.6.egg/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/seafile/www/seafile-pro-server-6.1.1/seahub/seahub/__init__.py", line 3, in <module>
    from handlers import repo_created_cb, repo_deleted_cb
  File "/seafile/www/seafile-pro-server-6.1.1/seahub/seahub/handlers.py", line 17, in <module>
    from utils import SeafEventsSession
  File "/seafile/www/seafile-pro-server-6.1.1/seahub/seahub/utils/__init__.py", line 490, in <module>
    SeafEventsSession = seafevents.init_db_session_class(EVENTS_CONFIG_FILE)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/seafevents/db.py", line 89, in init_db_session_class
    Base.metadata.create_all(engine)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/sql/schema.py", line 3848, in create_all
    tables=tables)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1922, in _run_visitor
    with self._optional_conn_ctx_manager(connection) as conn:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1915, in _optional_conn_ctx_manage
r
    with self.contextual_connect() as conn:
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2106, in contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2145, in _wrap_pool_connect
    e, dialect, self)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1456, in _handle_dbapi_exception_n
oconnection
    exc_info
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 202, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2141, in _wrap_pool_connect
    return fn()
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 387, in connect
    return _ConnectionFairy._checkout(self)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 766, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 516, in checkout
    rec = pool._do_get()
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 1138, in _do_get
    self._dec_overflow()
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", line 60, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 1135, in _do_get
    return self._create_connection()
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 333, in _create_connection
    return _ConnectionRecord(self)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 461, in __init__
    self.__connect(first_connect_check=True)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 651, in __connect
    connection = pool._invoke_creator(self)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 105, in connect
    return dialect.connect(*cargs, **cparams)
  File "/seafile/www/seafile-pro-server-6.1.1/pro/python/SQLAlchemy-1.1.3-py2.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 385, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1045, "Access denied for user 'seafile-cl'@'localhost' (using password: YES)")
Error:Seahub failed to start.

It seems that seahub can’t connect to mysql, whereas I can access to mysql with
mysql --host=localhost --user=seafile-cl --password="PASSWORD"

Here is my seahub_settings.py

# -*- coding: utf-8 -*-
SECRET_KEY = "g^+1o&_(&^)sw5e6l@%=8@($9rso(#%t*8)6yulfkyg72u#q2&"

FILE_SERVER_ROOT = 'https://DOMAIN/seafhttp'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'seahub-db',
        'USER': 'seafile-cl',
        'PASSWORD': 'PASSWORD',
        'HOST': '127.0.0.1',
        'PORT': '3306',
    }
}

I’ve to add that my password is composed of spaces, I don’t know if it’s possibly because of that.

Thank you.

MySQL distinguishes between localhost and 127.0.0.1. You can fix the problem by granting rights for your sql user to access from 127.0.0.1. localhost is being used when accessing mysql using a socket. That is what likely happens with your mysql command above.

See also https://dev.mysql.com/doc/refman/5.5/en/can-not-connect-to-server.html

Okay, thank you very much.
I don’t understand everything, because I can connect with the command
mysql --host=localhost --user=seafile-cl --password="PASSWORD"

but I’m unable to connect with the command
mysql -u seafil-cl -p

To fix this problem, I tried
GRANT ALL PRIVILEGES ON * . * TO 'seafile-cl'@'127.0.0.1;
and
FLUSH PRIVILEGES;
I’m not sure that all was OK, because both commands returned
Query OK, 0 rows affected (0.00 sec)

After a reboot, I can’t launch seahub.sh and I’m unable to connect to the database with the second command.

I don’t know if i tried that with the correct method, but I can’t find how to pass througt this problem.

mysql> SELECT User, Host, Password from user WHERE User = 'seafile-cl';
+------------+-----------+-------------------------------------------+
| User       | Host      | Password                                  |
+------------+-----------+-------------------------------------------+
| seafile-cl | localhost | *86016BFB3807070283C7AF8852C452A0C0D576E8 |
| seafile-cl | 127.0.0.1 |                                           |
+------------+-----------+-------------------------------------------+

However seafile-cl seems to be grant to connect localhost and 127.0.0.1.

I don’t know if you know were I went wrong.

I think the second entry needs a password as well.

I’ve add a passord in the second entry, but I’m steel unable to connect to mysql with the sencond command, and so unable to launch seahub too.

I fixed the problem with two steps:

  • First, I’ve created a new mysql user for seafile in mysql command prompt, with a password WITHOUT spaces (it’s important, because it doesn’t seem to work with spaces.

  • Then I’ve deleted all the seafile’s databases and recreate them.

Now, you just need to reinstall seafile, using the user and the databases created before.

It’ll work with spaces if you wrap the password in single quotes when you use the MySQL cli