Pymysql.err "Can't connect to MySQL server on u'localhost"

Hi,

i am doing a clean manual install for Ubuntu 16.04 as guided here Guide: Manual Install ERPNext on Ubuntu 16.xx & Debian v8 & 9 , and still unable to install ERPNext, both with development and production. it works until I reach bench new-site site1.local. I am getting this error

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

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/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 34, in new_site
verbose=verbose, install_apps=install_app, source_sql=source_sql, force=force)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 65, in _new_site
admin_password=admin_password, verbose=verbose, source_sql=source_sql,force=force, reinstall=reinstall)
File “/home/frappe/frappe-bench/apps/frappe/frappe/installer.py”, line 36, in install_db
create_database_and_user(force, verbose)
File “/home/frappe/frappe-bench/apps/frappe/frappe/installer.py”, line 60, in create_database_and_user
if force or (db_name not in dbman.get_database_list()):
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/db_schema.py”, line 549, in get_database_list
return [d[0] for d in self.db.sql(“SHOW DATABASES”)]
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 136, in sql
self.connect()
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 86, in connect
charset=‘utf8mb4’, use_unicode = True, conv = conversions)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/init.py”, line 90, in Connect
return Connection(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 706, in init
self.connect()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 963, in connect
raise exc
pymysql.err.OperationalError: (2003, “Can’t connect to MySQL server on u’localhost’ ([Errno 111] Connection refused)”)

Hi

You need to uninstall mysql clearly. And make sure you can install mysql completely. Then install frappe

Try to restart it manually using this commends

sudo systemctl stop mysql
/etc/init.d/mysql start
5 Likes

thank you for the reply. now re-installing mairadb

Starting mysql (via systemctl): mysql.serviceHimJob for mysql.service failed because the control process exited with error code. See “systemctl status mysql.service” and “journalctl -xe” for details.
failed!

Thak you all . its worked after removing and re installing mysql and mariadb

3 Likes