Fix MySQL startup error: 2002

2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"
This commit is contained in:
Worros 2009-11-27 20:19:43 +08:00
parent b60895a89f
commit a13ae41134
3 changed files with 13 additions and 0 deletions

View File

@ -27,5 +27,12 @@ class FpdbMySQLAccessDenied(FpdbDatabaseError):
def __str__(self):
return repr(self.value +" " + self.errmsg)
class FpdbMySQLNoDatabase(FpdbDatabaseError):
def __init__(self, value='', errmsg=''):
self.value = value
self.errmsg = errmsg
def __str__(self):
return repr(self.value +" " + self.errmsg)
class DuplicateError(FpdbError):
pass

View File

@ -473,6 +473,10 @@ class fpdb:
except Exceptions.FpdbMySQLAccessDenied:
self.warning_box("MySQL Server reports: Access denied. Are your permissions set correctly?")
exit()
except Exceptions.FpdbMySQLNoDatabase:
msg = "MySQL client reports: 2002 error. Unable to connect - Please check that the MySQL service has been started"
self.warning_box(msg)
exit
# except FpdbMySQLFailedError:
# self.warning_box("Unable to connect to MySQL! Is the MySQL server running?!", "FPDB ERROR")

View File

@ -106,6 +106,8 @@ class fpdb_db:
except MySQLdb.Error, ex:
if ex.args[0] == 1045:
raise FpdbMySQLAccessDenied(ex.args[0], ex.args[1])
elif ex.args[0] == 2002:
raise FpdbMySQLNoDatabase(ex.args[0], ex.args[1])
else:
print "*** WARNING UNKNOWN MYSQL ERROR", ex
elif backend == fpdb_db.PGSQL: