Question

How to launch database console to access mysqld.cnf?

So, I have been trying to set up a MySQL database to store my Python code and create a database of code. I have a droplet and got the MySQL database; I can launch the droplet console and access the MySQL database via Flags from the database Connection Details and get to mysql>, but the droplet isn’t the database. When I follow the instructions here: https://www.digitalocean.com/community/tutorials/how-to-allow-remote-access-to-mysql, this path breaks “/etc/mysql/mysql.conf.d/mysqld.cnf” after /etc there is no MySQL directory. Is there a way to access and launch the console the database is on?


Submit an answer


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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
April 4, 2024

Heya, @hyrschallsdamon

On top of what’s already mentioned you can also ensure that your firewall allows incoming connections on the MySQL port (default is 3306) from your remote IP address. You can do this using the ufw firewall if you’re using Ubuntu:

sudo ufw allow from your_remote_ip to any port 3306 sudo ufw reload

With these changes you should be able to connect to your MySQL database remotely using a MySQL client like MySQL Workbench or MySQL command-line client

Regards

Bobby Iliev
Site Moderator
Site Moderator badge
April 3, 2024

Hello Hyrschall,

Glad to hear you’re setting up a MySQL database to enhance your Python projects. It sounds like you’re on the right track, but let’s tackle the issue you’re facing with accessing the mysqld.cnf file.

First you would need to access your Droplet over SSH:

https://docs.digitalocean.com/products/droplets/how-to/connect-with-ssh/

Then to find the mysqld.cnf file, you can use the find command, which searches for files in a directory hierarchy.

sudo find / -type f -name "mysqld.cnf"

This command will search through the filesystem from the root directory (/) for any file named mysqld.cnf. Once you find the file, you can access and edit it using a text editor like nano or vim. For instance, if the file is located at /etc/mysql/mysql.conf.d/mysqld.cnf, you can edit it with:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Remember, after making changes to the mysqld.cnf file, it’s important to restart the MySQL service for the changes to take effect:

sudo systemctl restart mysql

Regarding remote access, as outlined in the DigitalOcean guide, make sure that the bind-address parameter in your mysqld.cnf file is set to 0.0.0.0. This setting allows MySQL to listen for connections on all network interfaces.

If you’re still unable to locate the file or face any issues, the MySQL version or the operating system might have a different configuration setup. Feel free to share more details about your setup and I will be happy to help further.

I hope this helps you move forward with setting up your database. If you have any more questions or run into issues, feel free to ask!

On a side note, if you want to store your actual code in MySQL directly, this isn’t a perfect fit. It’s better to store your code in Git and GitHub and use MySQL for storing data in there rather than the code itself:

https://github.com/

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel