title: MySQLdb and _mysql versions ncompatible: how to upgrade _mysql
body: <p>I'm running MySQLdb v1.2.3 and getting the following error:</p>
  
  <pre><code>LookupError: unknown encoding: utf8mb4
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/21517358/django-mysql-unknown-encoding-utf8mb4">This answer</a> suggests updating MySQLdb to version 1.2.5. I updated and am now getting this error:</p>
  
  <pre><code>ImportError: this is MySQLdb version (1, 2, 5, 'final', 1), but _mysql is version (1, 2, 3, 'final', 0)
  </code></pre>
  
  <p>I'm not sure how to go about updating <code>_mysql</code> or how this will change my setup. Is this just a python module or is it connected in some way to my MySQL server?</p>
  
  <p><strong>EDIT:</strong> I've tried running the following three methods:</p>
  
  <pre><code>sudo pip uninstall mysql-python
  sudo pip install mysql-python
  
  sudo pip uninstall mysql-python
  sudo pip install mysql-python==1.2.5
  
  sudo pip install mysql-python --upgrade
  </code></pre>
  
  <p>When uninstalling I get</p>
  
  <pre><code>/usr/local/lib/python2.7/dist-packages/_mysql.so
  /usr/local/lib/python2.7/dist-packages/_mysql_exceptions.py
  /usr/local/lib/python2.7/dist-packages/_mysql_exceptions.pyc
  Proceed (y/n)? y
  Successfully uninstalled MySQL-python-1.2.3
  </code></pre>
  
  <p>After that I am unable to import either <code>MySQLdb</code> or <code>_mysql</code> but reinstalling always gives me <code>_mysql</code> version 1.2.3.</p>
  
  <p><strong>SECOND EDIT / SOLUTION:</strong> Turns out <code>_mysql</code> was installed in two different places on the server. Uninstalling/installing, as above, upgraded <code>_mysql</code> to v1.2.5 but whenever I then imported <code>MySQLdb</code> precedence was given to the other version of <code>_mysql</code> which was not being touched by pip. </p>