How to Install and Enable MySQL Importer Plugin on QGIS 3.4

Hello everyone, welcome to my GIS website. QGIS is an extensible GIS software. We can add more features and functionality to QGIS by installing some Python plugins. These plugins are available from the online repository. We can easily search, download and install this plugin from QGIS. I was kindly interested with the MySQL Importer plugin. With this plugin, it will be possible to import the spatial data to the MySQL database using the ogr2ogr tool. But, this plugin requires the MySQL Python extension installed on our system. Because if you don’t have it, you will end up with the following error.

Let’s start over

Install MySQL Importer Plugin

Go to Plugin | Manage and Install Plugin. The plugin window will open up. Type mysql importer or scroll down until you find the MySQL Importer.

Click Install to start the installation process. On my first attempt, I got the following error

ModuleNotFoundError: No module named ‘MySQLdb’

Here is the screenshot of the error that I got.

How to Fix it?

If you have the same problem, we need to install MySQLclient in our Pyhon directory. In this case, we are going to install the mysqlclient package in the following directory:

C:\Program Files\QGIS 3.4\apps\Python37\Lib\site-packages

First, download the mysqlclient package from this link below:

https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient

Scroll down until you find the following section

Choose the version that matches your Python version and system architecture. Next, extract the .whl file using 7z. You can download 7z from this link. After extract, you will have several files and folders.

Simply copy all the files and folders into the Python directory. In this case:

C:\Program Files\QGIS 3.4\apps\Python37\Lib\site-packages

Now, repeat the MySQL Importer installation step. If the installation is successful, you will see the MySQL Importer menu appear under the Database menu.

Now, you can start to import your GIS dataset to your MySQL Server using this MySQL Importer tool.