I was following this tutorial (https://www.digitalocean.com/community/tutorials/how-to-connect-to-managed-database-ubuntu-18-04#connecting-to-a-managed-mysql-database) and despite this when I start my bot it gives me this error.
Traceback (most recent call last):
File "/home/peppe/.venvs/discord/lib/python3.8/site-packages/mysql/connector/connection_cext.py", line 232, in _open_connection
self._cmysql.connect(**cnx_kwargs)
_mysql_connector.MySQLInterfaceError: Can't connect to MySQL server on 'discordbotdatabase....com:3306' (4)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "LMIIBotDevelopment.py", line 29, in <module>
lmiibot_db = mysql.connector.connect(
File "/home/peppe/.venvs/discord/lib/python3.8/site-packages/mysql/connector/__init__.py", line 272, in connect
return CMySQLConnection(*args, **kwargs)
File "/home/peppe/.venvs/discord/lib/python3.8/site-packages/mysql/connector/connection_cext.py", line 85, in __init__
self.connect(**kwargs)
File "/home/peppe/.venvs/discord/lib/python3.8/site-packages/mysql/connector/abstracts.py", line 1003, in connect
self._open_connection()
File "/home/peppe/.venvs/discord/lib/python3.8/site-packages/mysql/connector/connection_cext.py", line 232, in _open_connection
self._cmysql.connect(**cnx_kwargs)
KeyboardInterrupt
This is the code I use to connect it
import mysql.connector
lmiibot_db = mysql.connector.connect(
host="discordbotdatabase...com",
user="doadmin",
passwd="password",
database="lmiibot",
auth_plugin="mysql_native_password",
)
How could I do? I’m going crazy
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hi there,
As far as I can see from the error you have not specified the correct Managed Database port and your python application is trying to connect on the default one:
Can't connect to MySQL server on 'discordbotdatabase....com:3306'
To fix that, you need to specify the Managed MySQL database port.
Let me know how it goes! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.