MySQL configuration

From Smith family
Jump to: navigation, search
Server setup
← Previous Next →
Desktop mail forwarding PostgreSQL

If MySQL isn't already installed, install it:

root@server:~# apt-get install mysql-server mysql-client

Passwords

The first thing is to add passwords to the MySQL accounts. root accounts for MySQL are created with no passwords (but note that you're asked for them even during a graphical package install). The MySQL documentation has full instructions for how to do this, but in summary the steps are:

  • Add passwords to the root accounts
root@server:~# mysql -u root -p
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');

Remote access

If you want to access MySQL databases from a remote machine, you'll need to have MySQL accept connections across the network. Edit /etc/mysql/mysql.conf.d/mysql.cnf and change the bind-address entry to be the IP of the machine:

Note to self: use machine name, not IP number

bind-address            = server.domain.tld

The restart MySQL:

root@server:~# systemctl restart mysql.service

Note that the firewall is configured to only allow connections to MySQL from machines on the LAN.

See also

Here are a few pages that are useful guides or provide background and context.