MySQL configuration

From Smith family

Jump to: navigation, search
Server setup
← Previous Next →
MDA (Dovecot) Web server

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 anonymous user accounts
root@server:~# mysql -u root
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR ''@'host_name' = PASSWORD('newpwd');
where host_name is the name of this host, e.g. server.
(seemingly not needed for Ubuntu 10.04)
  • Add passwords to the root accounts
root@server:~# mysql -u root
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/my.cnf and change the bind-address entry to be the IP of the machine:

bind-address            = 192.168.2.252

The restart MySQL:

root@server:~# /etc/init.d/mysql restart

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.

Personal tools