Its possible to connect to mysql in ubuntu in digital ocean?
ktrevid
HOBBYOP

4 months ago

It says that but my digital ocean its already configured to accept

$10 Bounty

2 Replies

4 months ago

It should be possible, to connect to any MySQL database via public networking during build. Have you confirmed that your MySQL database is indeed reachable (for example by just connecting to it locally)?


bytekeim
PRO

4 months ago

yeah it's definitely possible, i've done this before on my DO droplets.

first thing - check your mysql config. edit /etc/mysql/mysql.conf.d/mysqld.cnf and look for the bind-address line. if it's set to 127.0.0.1 you need to change it to 0.0.0.0 so it accepts external connections. after that just restart mysql with sudo systemctl restart mysql

also make sure your firewall isn't blocking it. run sudo ufw allow 3306/tcp to open the port. you can check with sudo ufw status

for the user permissions, you'll need to create a user that can connect remotely. log into mysql as root and run something like:

sql

CREATE USER 'youruser'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'youruser'@'%';
FLUSH PRIVILEGES;

one thing people forget a lot is the Digital Ocean firewall itself (separate from UFW). go into your droplet settings in the DO dashboard and make sure port 3306 is allowed in the cloud firewall rules.

then test it from another machine with mysql -h your_ip_address -u youruser -p

if you're still having issues let me know what error message you're getting and i can help narrow it down


Loading...