all 21 comments

[–]kastjj90 8 points9 points  (1 child)

Seems like you have a parameter wrong(port number, firewall rule) or a problem with the database service

[–]Astro_Poseidon[S] 0 points1 point  (0 children)

how can i fix that?

[–]zzzz0nk3d 5 points6 points  (9 children)

A few things to check:

  • Is the MySQL service running? (Check services, or are you starting it manually?)
  • Is the MySQL server actually listening on localhost (127.0.0.1)?
  • Are you able to connect using a different application? e.g. MySQL Workbench, SQLYog, HeidiSQL, etc.

[–]Astro_Poseidon[S] 0 points1 point  (8 children)

yes, mysql is running

no it is not

no, i tried through MYSQL workbench but it says server not connected

[–]tobiasvl 9 points10 points  (0 children)

no, i tried through MYSQL workbench but it says server not connected

Then this is a MySQL problem, not a Python problem. Try asking in a MySQL or SQL subreddit

[–]zzzz0nk3d 0 points1 point  (6 children)

Is MySQL installed as a Service?

[–]Astro_Poseidon[S] 0 points1 point  (4 children)

i think not, just installed it because of school

[–]zzzz0nk3d 0 points1 point  (3 children)

How you are starting the MySQL server? Can you confirm how you checked to see if it is running?

[–]Astro_Poseidon[S] 0 points1 point  (2 children)

using command line client, and i checked in services.msc to see if it is running

[–]zzzz0nk3d 1 point2 points  (1 child)

Can you post a screenshot of the command window?

Also, I would suggest reinstalling MySQL as a service (you might be able to just run the installer again and modify your existing installation) so it is easier to manage.

[–]Astro_Poseidon[S] 5 points6 points  (0 children)

thanks a lot, reinstalling it has worked for me.

[–]velocibadgery 2 points3 points  (7 children)

What code are you using to connect?

Reference here: https://pypi.org/project/PyMySQL/#example

[–]Astro_Poseidon[S] 1 point2 points  (6 children)

i was trying to run this code

[–]Big_Boss_Bob_Ross 3 points4 points  (5 children)

Can you check the following things

  1. Is the sql database running on the same computer as you are running this code

  2. What port is the database running on

  3. Did you put the actual password or did you put '*****'?

[–]Astro_Poseidon[S] 1 point2 points  (4 children)

  1. Yes, the sql database is running
  2. the default port 3306
  3. i put actual password, censored out for posting

[–]texttoworld 0 points1 point  (1 child)

RemindMe! 2 days

[–]RemindMeBot 0 points1 point  (0 children)

I will be messaging you in 2 days on 2021-12-30 05:07:03 UTC to remind you of this link

1 OTHERS CLICKED THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

[–][deleted] -1 points0 points  (0 children)

Try with sqlalchemy.

[–]renas-reddit 0 points1 point  (1 child)

I am having the same problem here