# MySQL DB with MySQL Client Install Failure

**URL:** <https://forum.codewithmosh.com/t/mysql-db-with-mysql-client-install-failure/13856>\
**Category:** Django\
**Created:** [July 21, 2022, 7:45pm UTC](https://forum.codewithmosh.com/t/mysql-db-with-mysql-client-install-failure/13856 "2022-07-21T19:45:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![OldieButGoodie](https://avatars.discourse-cdn.com/v4/letter/o/13edae/32.png) [@OldieButGoodie](https://forum.codewithmosh.com/u/OldieButGoodie)\
**Post date:** [July 21, 2022, 7:45pm UTC](https://forum.codewithmosh.com/t/mysql-db-with-mysql-client-install-failure/13856/1 "2022-07-21T19:45:27Z")

</div>

Installing MySQL Client fails in Django. See Error Messages Below.

Is there an elegant solution available for Django 4.0.6 and MySQL 8.0.29  
and MySQL Client 2.1.1

macOS Monterey 12.4 Chip Apple M1 MAX Memory 64GB

IF not, how do we proceed with Mosh Purchased Courses?  
Are the following instructions viable:

[https://www.dev2qa.com/how-to-connect-mysql-databse-in-django-project/](https://www.dev2qa.com/how-to-connect-mysql-databse-in-django-project/)

Installing mysqlclient…  
Error: An error occurred while installing mysqlclient!  
Error text: Collecting mysqlclient  
Downloading mysqlclient-2.1.1.tar.gz (88 kB)  
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 88.1/88.1 kB 167.8 kB/s eta 0:00:00  
Preparing metadata (setup.py): started  
Preparing metadata (setup.py): finished with status ‘error’

error: subprocess-exited-with-error

× python setup.py egg\_info did not run successfully.  
│ exit code: 1  
╰─\> [16 lines of output]  
/bin/sh: mysql\_config: command not found  
/bin/sh: mariadb\_config: command not found  
/bin/sh: mysql\_config: command not found  
Traceback (most recent call last):  
File “”, line 2, in   
File “”, line 34, in   
File “/private/var/folders/67/g6ljn0wn3gd2hz1n0\_9p0dtc0000gn/T/pip-install-lxstynij/mysqlclient\_aaa08edd50934ae9a0946d998dab1cd2/setup.py”, line 15, in   
metadata, options = get\_config()  
File “/private/var/folders/67/g6ljn0wn3gd2hz1n0\_9p0dtc0000gn/T/pip-install-lxstynij/mysqlclient\_aaa08edd50934ae9a0946d998dab1cd2/setup\_posix.py”, line 70, in get\_config  
libs = mysql\_config(“libs”)  
File “/private/var/folders/67/g6ljn0wn3gd2hz1n0\_9p0dtc0000gn/T/pip-install-lxstynij/mysqlclient\_aaa08edd50934ae9a0946d998dab1cd2/setup\_posix.py”, line 31, in mysql\_config  
raise OSError(“{} not found”.format(\_mysql\_config\_path))  
OSError: mysql\_config not found  
mysql\_config --version  
mariadb\_config --version  
mysql\_config --libs  
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.  
error: metadata-generation-failed

× Encountered error while generating package metadata.  
╰─\> See above for output.

note: This is an issue with the package mentioned above, not pip.  
hint: See above for details.

This is likely caused by a bug in mysqlclient. Report this to its maintainers.  
✘ Installation Failed

---

<div class="post-metadata">

**Author:** ![tooTALLtim](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/tootalltim/32/5469_2.png) [@tooTALLtim](https://forum.codewithmosh.com/u/tooTALLtim)\
**Post date:** [August 4, 2022, 6:35pm UTC](https://forum.codewithmosh.com/t/mysql-db-with-mysql-client-install-failure/13856/2 "2022-08-04T18:35:40Z")

</div>

I had basically the same issue in Ubuntu, and found I needed to install the “python3-dev default-libmysqlclient-dev build-essential” despite already having installed MySQL previously and verifying it worked in my VS Code terminal.

I ran

`sudo apt-get install python3-dev default-libmysqlclient-dev build-essential`

and then was able to successfully install mysql client in my virtual environment! Please see what you need to run for your OS.

Reference: [Command errored out with exit status 1: python setup.py egg\_info Check the logs for full command output while installing mysqlclient - Stack Overflow](https://stackoverflow.com/questions/63342767/command-errored-out-with-exit-status-1-python-setup-py-egg-info-check-the-logs)

---

<div class="post-metadata">

**Author:** ![OldieButGoodie](https://avatars.discourse-cdn.com/v4/letter/o/13edae/32.png) [@OldieButGoodie](https://forum.codewithmosh.com/u/OldieButGoodie)\
**Post date:** [August 5, 2022, 5:51pm UTC](https://forum.codewithmosh.com/t/mysql-db-with-mysql-client-install-failure/13856/3 "2022-08-05T17:51:45Z")

</div>

The url provided does not exist or is an incorrect url.

Appreciate your help. Could you check on the url needed?

---

<div class="post-metadata">

**Author:** ![tooTALLtim](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/tootalltim/32/5469_2.png) [@tooTALLtim](https://forum.codewithmosh.com/u/tooTALLtim)\
**Post date:** [August 6, 2022, 1:28am UTC](https://forum.codewithmosh.com/t/mysql-db-with-mysql-client-install-failure/13856/4 "2022-08-06T01:28:20Z")

</div>

Yep, does this work?

> <https://stackoverflow.com/questions/63342767/command-errored-out-with-exit-status-1-python-setup-py-egg-info-check-the-logs>

Also see their github for more installation info:

> **[GitHub - PyMySQL/mysqlclient: MySQL database connector for Python (with Python...](https://github.com/PyMySQL/mysqlclient)**
>
> MySQL database connector for Python (with Python 3 support) - GitHub - PyMySQL/mysqlclient: MySQL database connector for Python (with Python 3 support)

---

<div class="post-metadata">

**Author:** ![OldieButGoodie](https://avatars.discourse-cdn.com/v4/letter/o/13edae/32.png) [@OldieButGoodie](https://forum.codewithmosh.com/u/OldieButGoodie)\
**Post date:** [August 21, 2022, 4:15pm UTC](https://forum.codewithmosh.com/t/mysql-db-with-mysql-client-install-failure/13856/5 "2022-08-21T16:15:19Z")

</div>

Had to use home-brew to install mysql and mysqlclient. Ran commands un these two commands in your terminal to add Homebrew to your PATH:  
echo ‘eval “$(/opt/homebrew/bin/brew shellenv)”’ \>\> /Users/ **your profile** /.zprofile  
eval “$(/opt/homebrew/bin/brew shellenv)”  
We’ve installed your MySQL database without a root password. To secure it run:  
mysql\_secure\_installation

MySQL is configured to only allow connections from localhost by default. To connect run:  
mysql -uroot  
We’ve installed your MySQL database without a root password. To secure it run:  
mysql\_secure\_installation

MySQL is configured to only allow connections from localhost by default

To connect run:  
mysql -uroot  
brew unlink mysql && brew link mysql

johnkpeterson@Johns-MacBook-Pro ~ % brew unlink mysql && brew link mysql

Unlinking /opt/homebrew/Cellar/mysql/8.0.30… 98 symlinks removed.

Linking /opt/homebrew/Cellar/mysql/8.0.30… 98 symlinks created.  
mysql\_secure\_installation- Run these two commands in your terminal to add Homebrew to your PATH:

Appreciate all of the help

---

<div class="post-metadata">

**Author:** ![OldieButGoodie](https://avatars.discourse-cdn.com/v4/letter/o/13edae/32.png) [@OldieButGoodie](https://forum.codewithmosh.com/u/OldieButGoodie)\
**Post date:** [August 21, 2022, 4:36pm UTC](https://forum.codewithmosh.com/t/mysql-db-with-mysql-client-install-failure/13856/6 "2022-08-21T16:36:10Z")

</div>

**Thank You** - Your suggestion:Thank you. **Your suggestions.** DATABASES = {‘default’:{ ‘ENGINE’: ‘mysql.connector.django’, ‘NAME’: ‘KMSFront’, ‘USER’: ‘root’, ‘PASSWORD’: ‘PWPWL’, ‘HOST’: ‘127.0.0.1’ ‘PORT’: 3306, ‘OPTIONS’: {‘autocommit’: True }}}. **Error Message:** “raise ImproperlyConfigured(django.core.exceptions.ImproperlyConfigured: ‘mysql.connector.django’ isn’t an available database backend or couldn’t be imported. Check above exception. Use one of the built-in backends, use ‘django.db.backends.XXX’, where XXX is one of: ‘mysql’, ‘oracle’, ‘postgresql’, ‘sqlite3’” **Updated**  **Environment** = macOS Monterey V12.5 M1Max with Visual Studio Code + Python 3.10.6 + Django 4.1 + PIP3. Have successfully installed mysql-connector-python-8.0.30. Current dbsqlite3 has populated tables. When I run python manage.py migrate from dbsqlite3 to MySQL Community 8.0.30 the error messages include “Did you install mysqlclient.” Oracle documentation indicates the mysql-connector-python should be used and is all that is needed. Current DATABASES = { ‘default’: { ‘ENGINE’: ‘django.db.backends.mysql’, ‘NAME’: ‘DatabaseName’, (These are the same settings in MySQL Workbench and mySQL that is running in shared mode) ‘HOST’: ‘127.0.0.1:3306’, ‘USER’: ‘root’, ‘PASSWORD’: ‘DDDDDD’,

---

<div class="post-metadata">

**Author:** ![cristydavidd](https://avatars.discourse-cdn.com/v4/letter/c/d9b06d/32.png) [@cristydavidd](https://forum.codewithmosh.com/u/cristydavidd)\
**Post date:** [November 8, 2022, 7:11am UTC](https://forum.codewithmosh.com/t/mysql-db-with-mysql-client-install-failure/13856/7 "2022-11-08T07:11:49Z")

</div>

In some of the ways, spacing and the order of parameters in the MySql connection string does matters. So, stick to the standard format:

`MysqlConn.ConnectionString = "Server=localhost;Port=1234;Database=My_Mysql_Database;Uid=root;Pwd=root;"`

If the above connection string fails, try update your c# mysql connection string as shown below (without port variable as well):

`MysqlConn.ConnectionString = "Server=localhost;Database=My_Mysql_Database;Uid=root;Pwd=root;"`

Or, sometime the problem could be on your windows firewall, make sure your server allow access to all port associated with your [mysql](http://net-informations.com/q/faq/mysql.html) database.
