code pinguin
code pinguin

Reputation: 94

How to run MYSQL in MINGW64 on Windows10?

I really liked the environment of MINGW64 on Windows10 since Python, TMUX and VIM come in handy through Pacman. However, there's no MYSQL package available for MINGW64. How could I run/install MYSQL in MINGW64 on Windows10?

Upvotes: 1

Views: 2306

Answers (2)

Rainb
Rainb

Reputation: 2465

Thanks to this very recent pull request

you can just do (in mingw enviroment)

pacman -S ${MINGW_PACKAGE_PREFIX}-python-mysqlclient

Feel free to test in python

import MySQLdb

def test_connection():
    try:
        # Establish the connection
        conn = MySQLdb.connect(
            host="mysql-rfam-public.ebi.ac.uk",
            user="rfamro",
            passwd="",
            port=4497,
            db="Rfam"
        )
        
        # Create a cursor object to interact with the database
        cursor = conn.cursor()
        
        # Execute a simple SQL query (for example, fetching version information)
        cursor.execute("SELECT DATABASE();")
        
        # Fetch the result
        result = cursor.fetchone()
        print(f"Connected to database: {result[0]}")
        
    except MySQLdb.Error as e:
        print(f"Error: {e}")
        
    finally:
        # Close the cursor and connection
        if cursor:
            cursor.close()
        if conn:
            conn.close()

if __name__ == "__main__":
    test_connection()

This uses a public MySql server

Upvotes: 0

code pinguin
code pinguin

Reputation: 94

I found a little trick since I was not successful in building the package for MingW64. I downloaded the mariadb-10.4.11-winx64.msi from the mariadb download site and install the usual way. Added the MariaDB in the path:

export PATH=$PATH:''C:\Program Files\MariaDB 10.4\bin'

Install winpty using pacman:

pacman -Syu winpty

Enter winpty mysql -u root -p:

MariaDB on MingW64

Upvotes: 2

Related Questions