I can’t figure out how would I access my MySQL instance that has been created as a part of one-click LAMP installation when creating droplet.
Specifically, where will I find the hostname, username, password, port for connecting to MySQL?
Can I connect to it using MySQL Workbench client installed on my local machine? Or will I have to connect through command line? If yes, how?
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.
By default, MySql is only accessible on the local host as it’s bound to
127.0.0.1:3306
. You can see this in it’s configuration file:If you comment out that line and restart MySql (
sudo service mysql restart
), it will become available remotely.When you first log on to the server, the root MySql password is displayed:
Especially if you plan on allowing remote access to the database, run
mysql_secure_installation
in order to disable remote access via the root account. After you’ve done this, you can create a user with remote access.Replace the highlighted values with the ones you need.
So to answer your question, if you want to allow remote access you must set the username and password yourself. The “host” is the IP address of your server and the port is 3306.