Mysql error in erpnext

Mysql error while logging in to root user in erpnext

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

What are you trying to do?

trying to restart the mysql

Its not starting and my erpnext site is not working

So what command did you run?

service mysql restart
```?

yes i run this command but it is not starting the mysql

mysqld failed while starting

I tried to login into the mysql server

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

I am facing this issue

It is difficult to guess without any logs. Also, it also a bit off topic for this forum.

I got the same error when i checked in mysql error logs

But erpnext will work thorugh mysql right

Hi
Please give details of this command:

netstat -tan | grep 3306

Try to see your /var/log/mysql if nothing displays there activate the log in my.cf of mysql server and check.

Thanks

Shafeek

It is displaying some mariadb error logs

Santosh,

Please check whether mysql is really installed (or half installed) because the mysql socket is not created in the specified directory.
Launch this command:
mysqld_safe&

Check if my mysql is running by service mysql status
Otherwise, do an apt-get install mariadb-server. If needed do a apt-get --purge remove mariadb-server before.
Hope it helps

S

1 Like

see actually i have error in brower

502 Bad Gateway
nginx/1.4.6 (Ubuntu)

What i am thinking is its a problem with mysql server.

When i tried to restart the mysql it is not starting, and i tried ur steps but it not helped me, i have a data in my server, so tell what i have to do now

I have the same issue…

ERPNext was running OK for months and suddenly MariaDB can’t start.

Have you solved it? how?

hi all,

I just have another problem related to mysql in database socket.

I need to setup my mariadb database as multiple instances by mysqld_multi. So the socket file is not in standard as /var/run/mysqld/mysqld.sock, it is another file name, eg. /var/run/mysqld/mysqld1.sock. After i setup my database and restart erpnext, i found it has a error in:

File "/home/easystore/frappe-bench/apps/frappe/frappe/database.py", line 106, in sql
    self.connect()
File "/home/easystore/frappe-bench/apps/frappe/frappe/database.py", line 52, in connect
    use_unicode=True, charset='utf8')
File "/home/easystore/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
File "/home/easystore/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 193, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (2002, 'Can\'t connect to local MySQL server through socket \'/var/run/mysqld/mysqld.sock\' (2 "No such file or directory")')'

My solution is:

  1. adding a item into site_config.json as

    “db_unix_socket”: “/var/run/mysqld/mysqld3306.sock”,

  2. editing ~/frappe-bench/apps/frappe/frappe/database.py


    class Database:

    def init(self, host=None, user=None, password=None, ac_name=None, use_default = 0):

    self.password = password or frappe.conf.db_password
    self.value_cache = {}

             self.unix_socket = frappe.conf.db_unix_socket or None
    


    def connect(self):
    “”“Connects to a database as set in site_config.json.”“”
    warnings.filterwarnings(‘ignore’, category=MySQLdb.Warning)
    self._conn = MySQLdb.connect(user=self.user, host=self.host, passwd=self.password,
    use_unicode=True, charset=‘utf8’, unix_socket=self.unix_socket)
    self._conn.converter[246]=float

  3. start erpnext again, then it works.

1 Like

Thanks This Worked For Me. :slight_smile:

If you have used ERPNext, and liked it, then please help us spread the word by submitting your reviews on the following sites.

http://www.capterra.com/enterprise-resource-planning-software/spotlight/132657/ERPNext/Web%20Notes%20Technologies

http://alternativeto.net/software/erpnext/

https://www.getapp.com/operations-management-software/a/iwebnotes/

We as a community can achieve lot more than as individuals.

2 Likes