Troubleshooting "Connection Refused" Error when Connecting to MySQL with PyMySQL
When attempting to establish a connection to MySQL on localhost using PyMySQL, some users encounter the error "socket: [Errno 111] Connection refused." This can be frustrating, especially when MySQL is known to be running.
To understand the cause of this issue, let's examine two potential reasons:
pymysql.connect(db='base', user='root', passwd='pwd', unix_socket="/tmp/mysql.sock")
pymysql.connect(db='base', user='root', passwd='pwd', host='localhost', port=XXXX)
By addressing one of these potential causes, you should be able to successfully establish a connection to MySQL on localhost using PyMySQL.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3