Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysqlclient fails to build for MySQL >= 8.3.0 #688

Closed
etripier opened this issue Jan 30, 2024 · 7 comments · Fixed by #690
Closed

mysqlclient fails to build for MySQL >= 8.3.0 #688

etripier opened this issue Jan 30, 2024 · 7 comments · Fixed by #690

Comments

@etripier
Copy link

etripier commented Jan 30, 2024

Hi! I love your driver. It's fast and reliable.

Unfortunately, the MySQL team finally killed a couple of the APIs they've been threatening to remove for a while now - mysql_kill, mysql_shutdown, and mysql_ssl_set.

I fixed the issue here: etripier@ee1882e. I'd be more than happy to submit a PR to your repo.

diff --git a/src/MySQLdb/_mysql.c b/src/MySQLdb/_mysql.c
index 0612be2..4282ab3 100644
--- a/src/MySQLdb/_mysql.c
+++ b/src/MySQLdb/_mysql.c
@@ -524,7 +524,11 @@ _mysql_ConnectionObject_Initialize(
         mysql_options(&(self->connection), MYSQL_OPT_LOCAL_INFILE, (char *) &local_infile);

     if (ssl) {
-        mysql_ssl_set(&(self->connection), key, cert, ca, capath, cipher);
+        mysql_options(&(self->connection), MYSQL_OPT_SSL_KEY, key);
+        mysql_options(&(self->connection), MYSQL_OPT_SSL_CERT, cert);
+        mysql_options(&(self->connection), MYSQL_OPT_SSL_CA, ca);
+        mysql_options(&(self->connection), MYSQL_OPT_SSL_CAPATH, capath);
+        mysql_options(&(self->connection), MYSQL_OPT_SSL_CIPHER, cipher);
     }
     if (ssl_mode) {
 #ifdef HAVE_ENUM_MYSQL_OPT_SSL_MODE
@@ -1789,10 +1793,11 @@ _mysql_ConnectionObject_kill(
 {
     unsigned long pid;
     int r;
+    char query[50];
     if (!PyArg_ParseTuple(args, "k:kill", &pid)) return NULL;
     check_connection(self);
     Py_BEGIN_ALLOW_THREADS
-    r = mysql_kill(&(self->connection), pid);
+    r = mysql_query(&(self->connection), snprintf(query, 50, "KILL %d", pid));
     Py_END_ALLOW_THREADS
     if (r) return _mysql_Exception(self);
     Py_RETURN_NONE;
@@ -2008,7 +2013,7 @@ _mysql_ConnectionObject_shutdown(
     int r;
     check_connection(self);
     Py_BEGIN_ALLOW_THREADS
-    r = mysql_shutdown(&(self->connection), SHUTDOWN_DEFAULT);
+    r = mysql_query(&(self->connection), "SHUTDOWN");
     Py_END_ALLOW_THREADS
     if (r) return _mysql_Exception(self);
     Py_RETURN_NONE;
@methane
Copy link
Member

methane commented Jan 30, 2024

thanks.

@phnahes
Copy link

phnahes commented Jan 30, 2024

Thanks!!! It worked for me!! :)

@zaphod72
Copy link

zaphod72 commented Jan 30, 2024

To install from etripier's commit:
pip install -e git+https://github.com/etripier/mysqlclient.git@ee1882e02e3c73910b1d6df86bbdce784edbb881#egg=mysqlclient

And don't trust me - make sure the commit id ee1...881 is what etripier links to above.

@Albertrrrr
Copy link

Deeply thanks!!

@epeisach
Copy link

epeisach commented Feb 2, 2024

Question: How far back will your changes work? Will it work back for myself 5.6* series? MariaDB 5.5? We are slowly transitioning from Centos 7 - which reaches EOL this year. Will your changes break things?

mysql 5.6 series does define MYSQL_OPT_SSL *

@methane
Copy link
Member

methane commented Feb 3, 2024

I don't know. They are not supported version.
If you are interested in it, take your time to check them.

methane added a commit that referenced this issue Feb 3, 2024
gnodar01 added a commit to CellProfiler/CellProfiler that referenced this issue Feb 7, 2024
problem:
- there are no wheels mysqlclient for mac, instead pip builds the wheel
- this has generally worked fine, but recently, for mysql >= 8.3.0, the MySQL team killed
  some APIs that have been deprecated for a while now, causing the
mysqlclient build to fail

solution:
- we can pin the brew install of mysql to < 8.3.0, or we can bump the
  pip install of mysqlclient to >= 2.2.3 which as of 2/4/24 has a patch: PyMySQL/mysqlclient#688
- later seems more "responsible"
gnodar01 added a commit to CellProfiler/CellProfiler that referenced this issue Feb 7, 2024
problem:
- there are no wheels mysqlclient for mac, instead pip builds the wheel
- this has generally worked fine, but recently, for mysql >= 8.3.0, the MySQL team killed
  some APIs that have been deprecated for a while now, causing the
mysqlclient build to fail

solution:
- we can pin the brew install of mysql to < 8.3.0, or we can bump the
  pip install of mysqlclient to >= 2.2.3 which as of 2/4/24 has a patch: PyMySQL/mysqlclient#688
- later seems more "responsible"
@j00bar
Copy link

j00bar commented Feb 12, 2024

If you're using Homebrew, upgraded to 8.3.0 already, and aren't ready to upgrade your client library to 2.2.4, I put some simple instructions to get your dev environment working again: https://i-am-j.ag/blog/posts/python-mysql-8.3.0-homebrew/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants