Chapter 19. Database configuration

Table of Contents

19.1. Enabling remote MySQL access

Initially the root password for the database is the same as that of the admin user used to to connect to your machine via SSH or SFTP. To change this you can use the phpMyAdmin interface.

As a general rule, each application should have its own username and access rights, to make sure that there is a degree of separation between all the applications on a server. This can all be done through the phpMyAdmin interface.

19.1. Enabling remote MySQL access

As a security measure, your MySQL server is not opened to the world. However you might wish to access it remotely for performing queries, or allowing other hosts to otherwise communicate with it.

Your MySQL server should be configured already to listen upon your external IP addresses. Therefore only two steps are needed to configure remote access: opening the firewall, and adding a user with remote privileges to the database.

Opening the firewall for MySQL

To open a hole in the firewall to the whole internet, you should create the file /etc/symbiosis/firewall/incoming.d/55-mysql. It is a good idea to restrict access to the database to a list of known IP addresses. To do this simply add IP addresses to the above file, one per line.

Chapter 16, Firewall Reference gives full details of how the firewall works.

Adding a user with remote privileges

There are two ways to do this, either using the MySQL command line tool, or via phpMyAdmin. This section will cover doing it with the latter.

  1. In phpMyAdmin, select the Privileges link from the front page, once you’ve logged in to it as root — see Chapter 7, Managing the MySQL database for details on how to do this.

  2. The privileges section will present a User Overview, at the bottom of which there is a link to Add a new user.

  3. In the Add a new user screen, fill out the details in the form as needed, making sure that the Host field is set to Any host.

    The privileges tick boxes lower down should be selected carefully. Most applications will need at least those in the Data section, and some of those in the Structure section. Check the documentation of the software you’re using to see what it requires.

    If you want an account with all privileges, select check all.

  4. Once you’re satisfied with everything, click Go. This will confirm that a user has been created.

  5. Now return to the home screen by clicking the phpMyAdmin logo at the top left of the screen.

  6. Finally, on the front page click the Reload privileges link to make sure MySQL knows about this new user.

You should now be able to access the MySQL database remotely, using this new username and password.