One hot gym - can’t connect to MySQL server on Ubuntu

I’m getting this issue on Ubuntu Desktop 64 bit 18.04 after following the install instructions from here: Installing NuPIC on Ubuntu 12

When running python swarm.py it throws following error:

WARNING:nupic.database.client_jobs_dao:[] First failure in <function connect at 0x7f5b74ef6398>; initial retry in 0.1 sec.; timeoutSec=300. Caller stack:
  File "swarm.py", line 111, in <module>
    swarm(INPUT_FILE)
  File "swarm.py", line 103, in swarm
    modelParams = swarmForBestModelParams(SWARM_DESCRIPTION, name)
  File "swarm.py", line 80, in swarmForBestModelParams
    verbosity=0
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/swarming/permutations_runner.py", line 271, in runWithConfig
    return _runAction(runOptions)
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/swarming/permutations_runner.py", line 212, in _runAction
    returnValue = _runHyperSearch(runOptions)
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/swarming/permutations_runner.py", line 141, in _runHyperSearch
    search = _HyperSearchRunner(runOptions)
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/swarming/permutations_runner.py", line 412, in __init__
    self.__cjDAO = _clientJobsDB()
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/swarming/permutations_runner.py", line 376, in _clientJobsDB
    return cjdao.ClientJobsDAO.get()
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/support/decorators.py", line 56, in exceptionLoggingWrap
    return func(*args, **kwargs)
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/database/client_jobs_dao.py", line 548, in get
    cjDAO.connect()
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/support/decorators.py", line 56, in exceptionLoggingWrap
    return func(*args, **kwargs)
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/support/decorators.py", line 234, in retryWrap
    timeoutSec, ''.join(traceback.format_stack()), exc_info=True)
Traceback (most recent call last):
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/support/decorators.py", line 208, in retryWrap
    result = func(*args, **kwargs)
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/database/client_jobs_dao.py", line 633, in connect
    with ConnectionFactory.get() as conn:
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/database/connection.py", line 167, in get
    return cls._connectionPolicy.acquireConnection()
  File "/home/neo/.local/lib/python2.7/site-packages/nupic-1.0.6.dev0-py2.7.egg/nupic/database/connection.py", line 553, in acquireConnection
    dbConn = self._pool.connection(shareable=False)
  File "/home/neo/.local/lib/python2.7/site-packages/DBUtils-1.1-py2.7.egg/DBUtils/PooledDB.py", line 331, in connection
    con = self.steady_connection()
  File "/home/neo/.local/lib/python2.7/site-packages/DBUtils-1.1-py2.7.egg/DBUtils/PooledDB.py", line 279, in steady_connection
    *self._args, **self._kwargs)
  File "/home/neo/.local/lib/python2.7/site-packages/DBUtils-1.1-py2.7.egg/DBUtils/SteadyDB.py", line 134, in connect
    failures, ping, closeable, *args, **kwargs)
  File "/home/neo/.local/lib/python2.7/site-packages/DBUtils-1.1-py2.7.egg/DBUtils/SteadyDB.py", line 186, in __init__
    self._store(self._create())
  File "/home/neo/.local/lib/python2.7/site-packages/DBUtils-1.1-py2.7.egg/DBUtils/SteadyDB.py", line 190, in _create
    con = self._creator(*self._args, **self._kwargs)
  File "/home/neo/.local/lib/python2.7/site-packages/PyMySQL-0.6.2-py2.7.egg/pymysql/__init__.py", line 88, in Connect
    return Connection(*args, **kwargs)
  File "/home/neo/.local/lib/python2.7/site-packages/PyMySQL-0.6.2-py2.7.egg/pymysql/connections.py", line 626, in __init__
    self._connect()
  File "/home/neo/.local/lib/python2.7/site-packages/PyMySQL-0.6.2-py2.7.egg/pymysql/connections.py", line 818, in _connect
    2003, "Can't connect to MySQL server on %r (%s)" % (self.host, e))
OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ((1251, u'Client does not support authentication protocol requested by server; consider upgrading MySQL client'))")

The fix was to run:

sudo mysql -u root

and then:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';
2 Likes

I can’t wait until we have a Python 3 Version of NuPIC without MySQL. :confounded:

This was extremely useful! Thank you so much for sharing!

1 Like