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

Connecting MySQL 5.1 container with python Error #423

Open
ammar3010 opened this issue Nov 30, 2023 · 0 comments
Open

Connecting MySQL 5.1 container with python Error #423

ammar3010 opened this issue Nov 30, 2023 · 0 comments

Comments

@ammar3010
Copy link

ammar3010 commented Nov 30, 2023

sudo docker pull vsamov/mysql-5.1.73
Using default tag: latest
latest: Pulling from vsamov/mysql-5.1.73
30d541b48fc0: Pull complete 
8ecd7f80d390: Pull complete 
46ec9927bb81: Pull complete 
2e67a4d67b44: Pull complete 
7d9dd9155488: Pull complete 
0b0a5e453b33: Pull complete 
e8a67e96f27e: Pull complete 
1a233fe4e788: Pull complete 
679cc5f63dfc: Pull complete 
cb730efe6d35: Pull complete 
7d5b1100bc65: Pull complete 
Digest: sha256:ef03d57334761ca1e3d93cbd9f83ee1f93dafd7cac74203fbf97f20ac098c82b
Status: Downloaded newer image for vsamov/mysql-5.1.73:latest
docker.io/vsamov/mysql-5.1.73:latest

sudo docker run -d --name jazz_db -p 3307:3306 -e MYSQL_ROOT_PASSWORD=12345 vsamov/mysql-5.1.73:latest
c2913eb089d3ac553c8547d99145ddd668424434ce144ae322c5c849924419a4

sudo docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED          STATUS         PORTS                                       NAMES
c2913eb089d3   vsamov/mysql-5.1.73:latest   "/entrypoint.sh mysq…"   12 seconds ago   Up 8 seconds   0.0.0.0:3307->3306/tcp, :::3307->3306/tcp   jazz_db

I have installed a sql container using the above procedure. Now i want to connect it to python and create a new database. I used mysql-python-connector

import mysql.connector

db = mysql.connector.connect(
    host="localhost",  # or use the IP of your Docker host machine
    port=3307,          # the port you mapped for the container (3307 in your case)
    user="root",
    password="12345"
)

It is resulting in this error:

MySQLInterfaceError                       Traceback (most recent call last)
File ~/anaconda3/envs/etl/lib/python3.10/site-packages/mysql/connector/connection_cext.py:308, in CMySQLConnection._open_connection(self)
    307 try:
--> 308     self._cmysql.connect(**cnx_kwargs)
    309     self._cmysql.converter_str_fallback = self._converter_str_fallback

MySQLInterfaceError: Access denied for user 'root'@'172.17.0.1' (using password: NO)

The above exception was the direct cause of the following exception:

ProgrammingError                          Traceback (most recent call last)
/home/aidev/VectraCom/db_migration/jazz_final_db_migration.ipynb Cell 20 line 1
----> 1 db = mysql.connector.connect(
      2     host="localhost",  # or use the IP of your Docker host machine
      3     port=3307,          # the port you mapped for the container (3307 in your case)
      4     user="root",
      5     password="12345"
      6 )

File ~/anaconda3/envs/etl/lib/python3.10/site-packages/mysql/connector/pooling.py:293, in connect(*args, **kwargs)
    290         raise ImportError(ERROR_NO_CEXT)
    292 if CMySQLConnection and not use_pure:
--> 293     return CMySQLConnection(*args, **kwargs)
    294 return MySQLConnection(*args, **kwargs)
...
    314         msg=err.msg, errno=err.errno, sqlstate=err.sqlstate
    315     ) from err
    317 self._do_handshake()

ProgrammingError: 1045 (28000): Access denied for user 'root'@'172.17.0.1' (using password: NO)
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

No branches or pull requests

1 participant