Question

phpMyAdmin One Click Installation

I just launched a phpMyAdmin droplet as a 1 click app. But I cannot connect to it from PHP on my local machine.

I’ve got it set up like so -

// database connection
$db_username = 'user';
$db_password = 'xxx';
$db_database = 'db_name';
$db_host = "123.456.789.100";

// connect to DB
try {
    $dbh = new PDO("mysql:host=$db_host;dbname=$db_database;charset=utf8", $db_username, $db_password);
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage(); die();
}

It works for my other databases, but not on digitalocean :/

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

Here’s the result of sudo ufw status

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
443                        ALLOW       Anywhere
80                         ALLOW       Anywhere
3306                       ALLOW       Anywhere
Anywhere                   ALLOW       MY IP ADDRESS
3306/tcp                   ALLOW       Anywhere
22 (v6)                    ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)
80 (v6)                    ALLOW       Anywhere (v6)
3306 (v6)                  ALLOW       Anywhere (v6)
3306/tcp (v6)              ALLOW       Anywhere (v6)

I’ve edited the /etc/mysql/my.cnf file like so -


#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
bind-address = 0.0.0.0

Then I tried to restart the server and got this error -

root@phpmyadmin-512mb-sgp1-01:~# sudo service mysql restart
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

So instead, I did a hard reset via the DO interface and I still get the following error: Error!: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.

Hi @hansen, thanks for your suggestion. I tried the tutorial and now I get the following error -

Error!: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.

I tried googling it and tried a handful of seemingly related tutorials to no avail :( any ideas?

Hi @12monkeys

Almost every one-click-app comes with firewall enabled, so you need to allow access to your MySQL from the outside if you want to use it remotely.

You can run this command to show the status of the firewall:

sudo ufw status

And run this command to allow access from anywhere to MySQL:

sudo ufw allow 3306

Please setup advanced, long users and password - or only allow connections from specific IP addresses. You can read more about the UFW firewall in this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-16-04