0

I’m getting the below error when trying to install a new site using command

bench --site site1.local install-app erpnext

This is a new installation on Windows Linux SubSustem running Ubuntu.

I’m able to login into mysql through command line using user root and the password which I had set during installation.

pymysql.err.OperationalError: (2003, “Can’t connect to MySQL server on u’localhost’ ([Errno 22] Invalid argument)”)

swadeesh@SWAD-PC:~/frappe-bench$ bench --site site1.local install-app erpnext
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
File "/home/swadeesh/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
File "/home/swadeesh/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
File "/home/swadeesh/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/swadeesh/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/swadeesh/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
File "/home/swadeesh/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
File "/home/swadeesh/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/commands/site.py", line 169, in install_app
    _install_app(app, verbose=context.verbose)
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/installer.py", line 52, in install_app
    frappe.clear_cache()
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/__init__.py", line 555, in clear_cache
    frappe.cache_manager.clear_user_cache()
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/cache_manager.py", line 42, in clear_user_cache
    clear_global_cache()
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/cache_manager.py", line 48, in clear_global_cache
    clear_website_cache()
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/website/render.py", line 291, in clear_cache
    for method in frappe.get_hooks("website_clear_cache"):
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/__init__.py", line 931, in get_hooks
    hooks = _dict(cache().get_value("app_hooks", load_app_hooks))
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py", line 79, in get_value
    val = generator()
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/__init__.py", line 905, in load_app_hooks
    for app in [app_name] if app_name else get_installed_apps(sort=True):
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/__init__.py", line 869, in get_installed_apps
    installed = json.loads(db.get_global("installed_apps") or "[]")
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/database/database.py", line 692, in get_global
    return self.get_default(key, user)
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/database/database.py", line 696, in get_default
    d = self.get_defaults(key, parent)
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/database/database.py", line 714, in get_defaults
    defaults = frappe.defaults.get_defaults(parent)
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/defaults.py", line 77, in get_defaults
    globald = get_defaults_for()
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/defaults.py", line 204, in get_defaults_for
    where parent = %s order by creation""", (parent,), as_dict=1)
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/database/database.py", line 122, in sql
    self.connect()
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/database/database.py", line 75, in connect
    self._conn = self.get_connection()
File "/home/swadeesh/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 89, in get_connection
    local_infile = frappe.conf.local_infile)
File "/home/swadeesh/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/__init__.py", line 94, in Connect
    return Connection(*args, **kwargs)
File "/home/swadeesh/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 325, in __init__
    self.connect()
File "/home/swadeesh/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 630, in connect
    raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on u'localhost' ([Errno 22] Invalid argument)")
James Z
  • 12,209
  • 10
  • 24
  • 44
Swadeesh
  • 576
  • 1
  • 4
  • 23

1 Answers1

0

I think you've enabled mysqld_safe mode. check if you've enable mysqld_safe mode using : sudo ps -aux | grep "mysqld_safe" if it's appear in output results then you've to disable it using following commands:

Stop mysql service and start it using /etc/init.d/mysql start to start it in normal mode.

Why you're not able to connect using Python Client because root user doesn't need mysql password for login into mysql but you will not be able to connect it using non-root user because of mysqld_safe mode on.

Nav
  • 61
  • 6