Skip to content

mysqlclient fails to build for MySQL >= 8.3.0 #688

Closed

Description

@etripier

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;

Activity

  1. methane commented on Jan 30, 2024

    @methane
    Member

    thanks.

  2. phnahes commented on Jan 30, 2024

    @phnahes

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

  3. zaphod72 commented on Jan 30, 2024

    @zaphod72

    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.

  4. Albertrrrr commented on Jan 31, 2024

    @Albertrrrr

    Deeply thanks!!

  5. epeisach commented on Feb 2, 2024

    @epeisach

    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 *

  6. methane commented on Feb 3, 2024

    @methane
    Member

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

  7. added a commit that references this issue on Feb 3, 2024
    720b804
  8. added 2 commits that reference this issue on Feb 7, 2024
  9. j00bar commented on Feb 12, 2024

    @j00bar

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions