Installing MySQL Server on Debian 7.5

The development server caters for the hosting of relational databases during the development of web-based applications.

Installing MySQL Server

We install the required packages by executing the following command in a “root” shell.

apt-get install mysql-server mysql-client

During installation, we will be prompted for a password for the MySQL “root” user – this password is valid for the user root@localhost and root@hostname.

Configuring MySQL Server

The configuration of MySQL Server is defined in the /etc/mysql/my.cnf file under the section [mysqld]. It is recommended to stop the daemon before making any configuration changes.

To stop the daemon, we stop the mysql service by executing the following command in a “root” shell.

service mysql stop

datadir

datadir         = /var/lib/mysql

By default, MySQL Server stores its databases under /var/lib/mysql. To store the databases under /home/mysql, we would move the current databases by executing the following command in a “root” shell.

mv /var/lib/mysql /home

To update the location, we set the value of datadir to /home/mysql in the /etc/mysql/my.cnf file.

datadir         = /home/mysql

port

port            = 3306

By default, MySQL Server listens on port 3306 for connections. By setting the value of port, MySQL Server can listen on a different port for connections.

bind-address

bind-address            = 127.0.0.1

By default, MySQL Server binds to the localhost IP address. By specifying an IP address for bind-address, MySQL Server will bind to that specific address.

bind-address            = 192.168.100.14

From the example above, MySQL Server will only bind to the IP address specified, namely 192.168.100.14.

To start the daemon, we start the mysql service by executing the following command in a “root” shell.

service mysql start
Advertisements

One thought on “Installing MySQL Server on Debian 7.5

Comments are closed.