How to Install MySQL Server on Ubuntu 11.10

MySQL Server

MySQL Server is the world’s most popular open source database. MySQL Database powers the most demanding Web, E-commerce and blogging tools. It has multi-threaded, multi-user, fast, robust SQL database server and intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software. In this post, i will share on how to install MySQL Server on Ubuntu 11.10 server.

To install MySQL, run the following command on your putty or terminal :

ehowstuff@ehowstuff:~$ sudo apt-get install mysql-server

Example :

ehowstuff@ehowstuff:~$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libnet-daemon-perl
  libplrpc-perl mysql-client-5.1 mysql-client-core-5.1 mysql-common mysql-server-5.1
  mysql-server-core-5.1
Suggested packages:
  libipc-sharedcache-perl libterm-readkey-perl tinyca mailx
The following NEW packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libnet-daemon-perl
  libplrpc-perl mysql-client-5.1 mysql-client-core-5.1 mysql-common mysql-server mysql-server-5.1
  mysql-server-core-5.1
0 upgraded, 12 newly installed, 0 to remove and 79 not upgraded.
Need to get 22.5 MB of archives.
After this operation, 54.5 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main mysql-common all 5.1.62-0ubuntu0.11.10.1 [11.8 kB]
Get:2 http://sg.archive.ubuntu.com/ubuntu/ oneiric/main libnet-daemon-perl all 0.48-1 [43.1 kB]
Get:3 http://sg.archive.ubuntu.com/ubuntu/ oneiric/main libplrpc-perl all 0.2020-2 [36.0 kB]
Get:4 http://sg.archive.ubuntu.com/ubuntu/ oneiric/main libdbi-perl i386 1.616-1build1 [852 kB]
Get:5 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main libmysqlclient16 i386 5.1.62-0ubuntu0.11.10.1 [1,805 kB]
Get:6 http://sg.archive.ubuntu.com/ubuntu/ oneiric/main libdbd-mysql-perl i386 4.019-1 [110 kB]
Get:7 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main mysql-client-core-5.1 i386 5.1.62-0ubuntu0.11.10.1 [88.3 kB]
Get:8 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main mysql-client-5.1 i386 5.1.62-0ubuntu0.11.10.1 [8,602 kB]
Get:9 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main mysql-server-core-5.1 i386 5.1.62-0ubuntu0.11.10.1 [4,632 kB]
Get:10 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main mysql-server-5.1 i386 5.1.62-0ubuntu0.11.10.1 [6,259 kB]
Get:11 http://sg.archive.ubuntu.com/ubuntu/ oneiric/main libhtml-template-perl all 2.10-1 [65.0 kB]
Get:12 http://sg.archive.ubuntu.com/ubuntu/ oneiric-updates/main mysql-server all 5.1.62-0ubuntu0.11.10.1 [6,406 B]
Fetched 22.5 MB in 3min 14s (116 kB/s)
Preconfiguring packages ...
Selecting previously deselected package mysql-common.
(Reading database ... 68437 files and directories currently installed.)
Unpacking mysql-common (from .../mysql-common_5.1.62-0ubuntu0.11.10.1_all.deb) ...
Selecting previously deselected package libnet-daemon-perl.
Unpacking libnet-daemon-perl (from .../libnet-daemon-perl_0.48-1_all.deb) ...
Selecting previously deselected package libplrpc-perl.
Unpacking libplrpc-perl (from .../libplrpc-perl_0.2020-2_all.deb) ...
Selecting previously deselected package libdbi-perl.
Unpacking libdbi-perl (from .../libdbi-perl_1.616-1build1_i386.deb) ...
Selecting previously deselected package libmysqlclient16.
Unpacking libmysqlclient16 (from .../libmysqlclient16_5.1.62-0ubuntu0.11.10.1_i386.deb) ...
Selecting previously deselected package libdbd-mysql-perl.
Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.019-1_i386.deb) ...
Selecting previously deselected package mysql-client-core-5.1.
Unpacking mysql-client-core-5.1 (from .../mysql-client-core-5.1_5.1.62-0ubuntu0.11.10.1_i386.deb) ...
Selecting previously deselected package mysql-client-5.1.
Unpacking mysql-client-5.1 (from .../mysql-client-5.1_5.1.62-0ubuntu0.11.10.1_i386.deb) ...
Selecting previously deselected package mysql-server-core-5.1.
Unpacking mysql-server-core-5.1 (from .../mysql-server-core-5.1_5.1.62-0ubuntu0.11.10.1_i386.deb) ...
Processing triggers for man-db ...
Setting up mysql-common (5.1.62-0ubuntu0.11.10.1) ...
Selecting previously deselected package mysql-server-5.1.
(Reading database ... 68814 files and directories currently installed.)
Unpacking mysql-server-5.1 (from .../mysql-server-5.1_5.1.62-0ubuntu0.11.10.1_i386.deb) ...
Selecting previously deselected package libhtml-template-perl.
Unpacking libhtml-template-perl (from .../libhtml-template-perl_2.10-1_all.deb) ...
Selecting previously deselected package mysql-server.
Unpacking mysql-server (from .../mysql-server_5.1.62-0ubuntu0.11.10.1_all.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Setting up libnet-daemon-perl (0.48-1) ...
Setting up libplrpc-perl (0.2020-2) ...
Setting up libdbi-perl (1.616-1build1) ...
Setting up libmysqlclient16 (5.1.62-0ubuntu0.11.10.1) ...
Setting up libdbd-mysql-perl (4.019-1) ...
Setting up mysql-client-core-5.1 (5.1.62-0ubuntu0.11.10.1) ...
Setting up mysql-client-5.1 (5.1.62-0ubuntu0.11.10.1) ...
Setting up mysql-server-core-5.1 (5.1.62-0ubuntu0.11.10.1) ...
Setting up mysql-server-5.1 (5.1.62-0ubuntu0.11.10.1) ...
mysql start/running, process 2687
Setting up libhtml-template-perl (2.10-1) ...
Setting up mysql-server (5.1.62-0ubuntu0.11.10.1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

Enter Password
MySQL
Re-Enter the password for verification
MySQL

Once the installation is complete, the MySQL server should be started automatically. Check MySQL service :

ehowstuff@ehowstuff:~$ sudo netstat -tap | grep mysql
[sudo] password for ehowstuff:
tcp        0      0 localhost:mysql         *:*                     LISTEN      2687/mysqld
ehowstuff@ehowstuff:~$

If the server is not running correctly, run this command to restart the MySQL database :

ehowstuff@ehowstuff:~$ sudo /etc/init.d/mysql restart

Example :

ehowstuff@ehowstuff:~$ sudo /etc/init.d/mysql restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop mysql ; start mysql. The restart(8) utility is also available.
mysql stop/waiting
mysql start/running, process 2853

Configure MySQL to listen for connections from allowed network, simply change the following to ip :

ehowstuff@ehowstuff:~$ sudo vi /etc/mysql/my.cnf
bind-address            = 192.168.1.0

Restart the MySQL database :

ehowstuff@ehowstuff:~$ sudo /etc/init.d/mysql restart

Example :

ehowstuff@ehowstuff:~$ sudo /etc/init.d/mysql restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop mysql ; start mysql. The restart(8) utility is also available.
mysql stop/waiting
mysql start/running, process 2968