Step 3: Configuring MySql

Fortunately with the Ubuntu 7.10 server installation, the MySql configuration is very easy. The database is fully configured for you out of the box and there are only two minor adjustments you might want to make:

  1. Configuring MySql to be accessed from outside of the server
  2. Setting up User Access.

Accessing MySql from the Outside

By default the MySql server is setup to only be accessed from the Ubuntu Server directly. However, setting up access to the outside world is pretty easy. To do this edit the MySql configuration file:
sudo vi /etc/mysql/my.cnf

Within the configuration file there are two key elements that you are going to want to review:

  1. The port your going to want to use to access the server (default = 3306)
  2. The IP address of the server (default = 127.0.0.1)

To change the listening port of the server, modify the port number in two locations within the configuration file:
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306

and
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306

Change the “port” value to what ever port number you want the server to listen on.

To change the IP Address that the server is listening to, edit this section of code:
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1

The bind-address setting tells the server what IP address to listen to for connections. By default this IP address is set to 127.0.0.1, which means that only requests from the server itself will be acknowledged. By changing this value to the LAN IP address of the server, it will acknowledge requests from other machines on the network.

If you configure your router to send requests to the configured port and IP address, you will be able to access your MySql server from anywhere on the internet. Please use caution when doing this as it reduces your database’s security and makes it more prone to attack.

One Response to “Step 3: Configuring MySql”

  1. Further Updates to the Ubuntu 7.10 Lamp Tutorial « Jocko’s Head Says:

    [...] [ Step 3: Configuring MySql ] [...]

Leave a Reply