Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
First time with mysql
#1
I'm a Python beginner, and tried to learn mysql, I typed this code:

import mysql.connector

mydb = mysql.connector.connect(user="pascal", database="gogo")

print(mydb) 
I tried to run the code but found errors:

Quote:pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Python$ python3 j3.py
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/mysql/connector/connection_cext.py", line 239, in _open_connection
self._cmysql.connect(**cnx_kwargs)
_mysql_connector.MySQLInterfaceError: Can't connect to MySQL server on '127.0.0.1:3306' (111)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "j3.py", line 3, in <module>
mydb = mysql.connector.connect(user="pascal", database="gogo")
File "/usr/local/lib/python3.8/dist-packages/mysql/connector/__init__.py", line 272, in connect
return CMySQLConnection(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/mysql/connector/connection_cext.py", line 85, in __init__
self.connect(**kwargs)
File "/usr/local/lib/python3.8/dist-packages/mysql/connector/abstracts.py", line 1009, in connect
self._open_connection()
File "/usr/local/lib/python3.8/dist-packages/mysql/connector/connection_cext.py", line 241, in _open_connection
raise errors.get_mysql_exception(msg=exc.msg, errno=exc.errno,
mysql.connector.errors.DatabaseError: 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3306' (111)
Reply


Messages In This Thread
First time with mysql - by pascal111 - Sep-24-2021, 08:12 PM
RE: First time with mysql - by bowlofred - Sep-24-2021, 08:19 PM
RE: First time with mysql - by pascal111 - Sep-24-2021, 08:24 PM
RE: First time with mysql - by bowlofred - Sep-24-2021, 09:03 PM
RE: First time with mysql - by deanhystad - Sep-24-2021, 08:51 PM
RE: First time with mysql - by Pedroski55 - Sep-25-2021, 07:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mysql and mysql.connector error lostintime 2 848 Oct-03-2023, 10:25 PM
Last Post: lostintime
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,842 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  Hard time trying to have clean MySQL to CSV program PierreSoulier 2 2,876 Jul-20-2018, 07:52 AM
Last Post: PierreSoulier

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020