M
M
Malmind2022-03-20 16:04:39
Flask
Malmind, 2022-03-20 16:04:39

What is the correct URI for mysql socket connection?

I'm trying to set up a connection to the database on the hosting, it says that the connection does not always work correctly via localhost, in my case it gives an error: sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost=' ([Errno -2] Name or service not known)"). With this data:
"mysql+pymysql://root:[email protected]/dbname"
In the configuration instructions they write that it is better to use a socket connection, but there is an example in django. Therefore, I went to Google, found this article , but it did not help, I also tried to replace unix_socket with localhost, which also did not help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Malmind, 2022-03-20
@Malmind

The problem was solved in an obscenely simple way:

"mysql+pymysql://user:[email protected]/db_name?unix_socket=/var/run/mysqld/mysqld.sock"
.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question