How to Install MySQL 5.5 Database on CentOS 6.2 using Remi Repository

MySQLRemi Repository or Les RPM de Remi repository is one of the popular 3rd party repositories for CentOS. (See http://rpms.famillecollet.com/) Remi repository provides and maintains the latest version of MySQL and PHP. Remi repository can be very useful
when you need the latest version of Linux Apache MySQL and PHP (LAMP) server. In this post, i will share on how to install MySQL 5.5 database on linux CentOS 6.2 using 3rd party repository, Remi repository.

Prerequisites :
How to Install Remi yum Repository on CentOS 6.2 x86 and x86_64

Simply run the following command to install latest MySQL Server packages :

[root@centos62 ~]# yum install mysql mysql-server -y
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
 * base: centos.ipserverone.com
 * extras: centos.ipserverone.com
 * remi: rpms.famillecollet.com
 * remi-test: rpms.famillecollet.com
 * updates: centos.ipserverone.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.i686 0:5.5.25-1.el6.remi will be installed
--> Processing Dependency: mysql-libs(x86-32) = 5.5.25-1.el6.remi for package: mysql-5.5.25-1.el6.remi.i686
---> Package mysql-server.i686 0:5.5.25-1.el6.remi will be installed
--> Processing Dependency: libaio.so.1(LIBAIO_0.4) for package: mysql-server-5.5.25-1.el6.remi.i686
--> Processing Dependency: libaio.so.1(LIBAIO_0.1) for package: mysql-server-5.5.25-1.el6.remi.i686
--> Processing Dependency: libaio.so.1 for package: mysql-server-5.5.25-1.el6.remi.i686
--> Running transaction check
---> Package libaio.i686 0:0.3.107-10.el6 will be installed
---> Package mysql-libs.i686 0:5.5.25-1.el6.remi will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package                   Arch              Version                        Repository         Size
====================================================================================================
Installing:
 mysql                     i686              5.5.25-1.el6.remi              remi              5.8 M
 mysql-server              i686              5.5.25-1.el6.remi              remi               10 M
Installing for dependencies:
 libaio                    i686              0.3.107-10.el6                 base               21 k
 mysql-libs                i686              5.5.25-1.el6.remi              remi              771 k

Transaction Summary
====================================================================================================
Install       4 Package(s)

Total download size: 17 M
Installed size: 77 M
Downloading Packages:
(1/4): libaio-0.3.107-10.el6.i686.rpm                                        |  21 kB     00:00
(2/4): mysql-5.5.25-1.el6.remi.i686.rpm                                      | 5.8 MB     12:36
(3/4): mysql-libs-5.5.25-1.el6.remi.i686.rpm                                 | 771 kB     01:35
(4/4): mysql-server-5.5.25-1.el6.remi.i686.rpm                               |  10 MB     21:41
----------------------------------------------------------------------------------------------------
Total                                                               8.0 kB/s |  17 MB     35:56
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-libs-5.5.25-1.el6.remi.i686                                                1/4

WARNING : This MySQL RPM is not an official Fedora/Redhat build and it
overrides the official one. Don't file bugs on Fedora Project nor Redhat.
Use dedicated forums http://forums.famillecollet.com/

  Installing : mysql-5.5.25-1.el6.remi.i686                                                     2/4
  Installing : libaio-0.3.107-10.el6.i686                                                       3/4
  Installing : mysql-server-5.5.25-1.el6.remi.i686                                              4/4

Installed:
  mysql.i686 0:5.5.25-1.el6.remi                mysql-server.i686 0:5.5.25-1.el6.remi

Dependency Installed:
  libaio.i686 0:0.3.107-10.el6                  mysql-libs.i686 0:5.5.25-1.el6.remi

Complete!

Start the MySQL daemon service :

[root@centos62 ~]# service mysqld start
Starting mysqld:                                           [  OK  ]

Login to database :

[root@centos62 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.25 MySQL Community Server (GPL) by Remi

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit

Check existing MySQL installed related packages :

[root@centos62 ~]# rpm -qa | grep mysql
compat-mysql51-5.1.54-1.el6.remi.i686
mysql-libs-5.5.25-1.el6.remi.i686
mysql-5.5.25-1.el6.remi.i686
mysql-server-5.5.25-1.el6.remi.i686

Check mysql version :

[root@centos62 ~]# mysql -V
mysql  Ver 14.14 Distrib 5.5.25, for Linux (i686) using readline 5.1
[root@centos62 ~]#

How to Configure MySQL Database Server on Ubuntu 11.10

MySQLIn this post, i will share with you on how to perform basic configuration on MySQL database server on Ubuntu 11.10 linux. As we know, MySQL Server is the world’s most popular open source database and the most demanding Web’s database especially for blogging and to run web applications. Assumed that MySQL database has been installed successfully :

Steps Configure MySQL Database Server on Ubuntu 11.10:

1. Change its bind address. This is for security purpose. Skip this step if the applications and MySQ are running on the same machine.

ehowstuff@ehowstuff:~$ vim /etc/mysql/my.cnf

Original bind address :

bind-address           = localhost

Change to something like this :

bind-address            = 192.168.1.0

2. Set mysql root password
Type the following to access the database :

ehowstuff@ehowstuff:~$ mysql -u root

At mysql console, type the following to set the password :

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');

3. Show user info on the database name’s mysql :

mysql> select user,host,password from mysql.user;
+------------------+-----------------------+-------------------------------------------+
| user             | host                  | password                                  |
+------------------+-----------------------+-------------------------------------------+
| root             | localhost             | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| root             | ehowstuff.example.com | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| root             | 127.0.0.1             | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| debian-sys-maint | localhost             | *0D767A6F1808D25DDAFB4AE43C9BA83063C89ED5 |
+------------------+-----------------------+-------------------------------------------+
4 rows in set (0.00 sec)

Alternatively, you can run this :

mysql> select user,host,password from user;
+------------------+-----------------------+-------------------------------------------+
| user             | host                  | password                                  |
+------------------+-----------------------+-------------------------------------------+
| root             | localhost             | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| root             | ehowstuff.example.com | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| root             | 127.0.0.1             | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| debian-sys-maint | localhost             | *0D767A6F1808D25DDAFB4AE43C9BA83063C89ED5 |
+------------------+-----------------------+-------------------------------------------+
4 rows in set (0.00 sec)

How to Install MySQL Server on Ubuntu 11.10

MySQL ServerMySQL 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

How to Install MySQL Server on CentOS 5.8

In this post, i will show on how to install MySQL database server on linux CentOS 5.8 server. MySQL server is a database server that can stores and retrieves data for the blog, websites and applications. It is one of the most popular most used in the internet especially for content management and blogging site. MySQL is a Relational Database Management System (RDBMS) that runs as a server providing multi-user access to a number of databases. For more information on MySQL, you can visit their website at www.mysql.com.

First of all, to install mysql server, you can simply execute this command :

[root@centos58 ~]# yum install mysql-server -y

Examples :

[root@centos58 ~]# yum install mysql-server -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.oscc.org.my
 * extras: mirror.issp.co.th
 * updates: mirror.issp.co.th
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.i386 0:5.0.95-1.el5_7.1 set to be updated
--> Processing Dependency: mysql = 5.0.95-1.el5_7.1 for package: mysql-server
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server
--> Processing Dependency: perl(DBI) for package: mysql-server
--> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15) for package: mysql-server
--> Processing Dependency: perl-DBI for package: mysql-server
--> Processing Dependency: libmysqlclient_r.so.15(libmysqlclient_15) for package: mysql-server
--> Processing Dependency: libmysqlclient.so.15 for package: mysql-server
--> Processing Dependency: libmysqlclient_r.so.15 for package: mysql-server
--> Running transaction check
---> Package mysql.i386 0:5.0.95-1.el5_7.1 set to be updated
---> Package perl-DBD-MySQL.i386 0:3.0007-2.el5 set to be updated
---> Package perl-DBI.i386 0:1.52-2.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package                    Arch             Version                      Repository           Size
====================================================================================================
Installing:
 mysql-server               i386             5.0.95-1.el5_7.1             updates             9.8 M
Installing for dependencies:
 mysql                      i386             5.0.95-1.el5_7.1             updates             4.9 M
 perl-DBD-MySQL             i386             3.0007-2.el5                 base                148 k
 perl-DBI                   i386             1.52-2.el5                   base                600 k

Transaction Summary
====================================================================================================
Install       4 Package(s)
Upgrade       0 Package(s)

Total download size: 15 M
Downloading Packages:
http://mirror.oscc.org.my/centos/5.8/os/i386/CentOS/perl-DBD-MySQL-3.0007-2.el5.i386.rpm: [Errno 12] Timeout: 
Trying other mirror.
(1/4): perl-DBD-MySQL-3.0007-2.el5.i386.rpm                                  | 148 kB     00:01
(2/4): perl-DBI-1.52-2.el5.i386.rpm                                          | 600 kB     00:12
(3/4): mysql-5.0.95-1.el5_7.1.i386.rpm                                       | 4.9 MB     02:36
(4/4): mysql-server-5.0.95-1.el5_7.1.i386.rpm                                | 9.8 MB     03:48
----------------------------------------------------------------------------------------------------
Total                                                                37 kB/s |  15 MB     07:09
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : perl-DBI                                                                     1/4
  Installing     : mysql                                                                        2/4
  Installing     : perl-DBD-MySQL                                                               3/4
  Installing     : mysql-server                                                                 4/4

Installed:
  mysql-server.i386 0:5.0.95-1.el5_7.1

Dependency Installed:
  mysql.i386 0:5.0.95-1.el5_7.1   perl-DBD-MySQL.i386 0:3.0007-2.el5   perl-DBI.i386 0:1.52-2.el5

Complete!

Note : MySQL server service daemon is mysqld.

To check Mysqld status :

[root@centos58 ~]# service mysqld status
mysqld is stopped

Start MySQL service :

[root@centos58 ~]# service mysqld start

Start MySQL service at first time :

[root@centos58 ~]# service mysqld start
Initializing MySQL database:  WARNING: The host 'centos58.ehowtuff.local' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h centos58.ehowtuff.local password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
                                                           [  OK  ]
Starting MySQL:                                            [  OK  ]

Stop MySQL service :

[root@centos58 ~]# service mysqld stop

Make mysqld daemon start at boot :

[root@centos58 ~]# chkconfig mysqld on

How to Configure MySQL Database Server on Fedora 16

On previous post (Install MySQL) i already shows how to install MySQL server on Fedora 16. MySQL server is a popular choice of database server that can stores and retrieves data for the blog, websites and applications. MySQL is a Relational Database Management System (RDBMS) that runs as a server providing multi-user access to a number of databases. For more information on MySQL, you can visit their website at www.mysql.com. This post will show you how to configure MySQL server on linux Fedora 16 server. This post assumed that you have set up local yum repository using your DVDROM and had installed minimal installation type Fedora 16.

1. How to configure mysql service run at boot on Fedora 16 :
To ensure that the mysql service run automatically at boot, please run this command :

[root@fedora16 ~]# systemctl enable mysqld.service

Example :

[root@fedora16 ~]# systemctl enable mysqld.service
ln -s '/lib/systemd/system/mysqld.service' '/etc/systemd/system/multi-user.target.wants/mysqld.service'

If you run chkconfig command, it will also return the same result as above :

[root@fedora16 ~]# chkconfig --levels 235 mysqld on
Note: Forwarding request to 'systemctl enable mysqld.service'.

or

[root@fedora16 ~]# chkconfig mysqld on
Note: Forwarding request to 'systemctl enable mysqld.service'.

2. How to start mysql service on Fedora 16 :

[root@fedora16 ~]# systemctl start mysqld.service

3. How to stop mysql service on Fedora 16 :

[root@fedora16 ~]# systemctl stop mysqld.service

4. How to restart mysql service on Fedora 16 :

[root@fedora16 ~]# systemctl restart mysqld.service

5. Configure basic security for MySQL server on Fedora 16.
As a root, simply run the following command :

[root@fedora16 ~]# mysql_secure_installation

Above command will perform the following task for you to ensure your MySQL server apply the basic security :
a) Set root password
b) Remove anonymous users
c) Disallow root login remotely
d) Remove test database and access to it
e) Reload privilege tables now

Examples :

[root@fedora16 ~]# mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

How to Install MySQL Database Server on Fedora 16

MySQL server is a popular choice of database server that can stores and retrieves data for the blog, websites and applications. MySQL is a Relational Database Management System (RDBMS) that runs as a server providing multi-user access to a number of databases. For more information on MySQL, you can visit their website at www.mysql.com. In this post, i will show on how to install MySQL database server on linux Fedora 16 server. This post assumed that you have set up local yum repository using your DVDROM and had installed minimal installation type Fedora 16.

1. To install mysql service, simply run the following command :

[root@fedora16 ~]# yum install mysql mysql-server -y

Examples of mysql installation :

[root@fedora16 ~]# yum install mysql mysql-server -y
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.i686 0:5.5.14-3.fc16 will be installed
---> Package mysql-server.i686 0:5.5.14-3.fc16 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package                Arch           Version                  Repository                     Size
====================================================================================================
Installing:
 mysql                  i686           5.5.14-3.fc16            Fedora16-Repository           4.2 M
 mysql-server           i686           5.5.14-3.fc16            Fedora16-Repository           7.8 M

Transaction Summary
====================================================================================================
Install       2 Packages

Total download size: 12 M
Installed size: 70 M
Downloading Packages:
----------------------------------------------------------------------------------------------------
Total                                                                51 MB/s |  12 MB     00:00
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-5.5.14-3.fc16.i686                                                         1/2
  Installing : mysql-server-5.5.14-3.fc16.i686                                                  2/2

Installed:
  mysql.i686 0:5.5.14-3.fc16                    mysql-server.i686 0:5.5.14-3.fc16

Complete!

2. How to configure mysql service run at boot on Fedora 16 :
To ensure that the mysql service run automatically at boot, please run this command :

[root@fedora16 ~]# systemctl enable mysqld.service

Example :

[root@fedora16 ~]# systemctl enable mysqld.service
ln -s '/lib/systemd/system/mysqld.service' '/etc/systemd/system/multi-user.target.wants/mysqld.service'

If you run chkconfig command, it will also return the same result as above :

[root@fedora16 ~]# chkconfig --levels 235 mysqld on
Note: Forwarding request to 'systemctl enable mysqld.service'.

or

[root@fedora16 ~]# chkconfig mysqld on
Note: Forwarding request to 'systemctl enable mysqld.service'.

3. How to start mysql service on Fedora 16 :

[root@fedora16 ~]# systemctl start mysqld.service

How to Secure MySQL Database Server

A Default MySQL installation is completely vulnerable to attacks. MySQL installation should be made as secure as possible. This is to protect the data collections and the information maintained by the MySQL server from unauthorized or anonymous access. In This post, i will share with you on how to secure your database server with the simple configuration and wizard.

Default and unsecured MySQL database:

    mysql> select user,host,password from mysql.user;
    +------+-----------+------------------+
    | user | host      | password         |
    +------+-----------+------------------+
    | root | localhost |                  |
    | root | CentOS57  |                  |
    | root | 127.0.0.1 |                  |
    |      | localhost |                  |
    |      | CentOS57  |                  |
    +------+-----------+------------------+
    5 rows in set (0.00 sec)
    

root password has not been set and anonymous user can access this MySQL server.

Simply run this command to secure MySQL server:

    [root@CentOS57 ~]# /usr/bin/mysql_secure_installation
    
    [root@CentOS57 ~]# /usr/bin/mysql_secure_installation
    
    
    
    
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    
    
    In order to log into MySQL to secure it, we'll need the current
    password for the root user.  If you've just installed MySQL, and
    you haven't set the root password yet, the password will be blank,
    so you should just press enter here.
    
    Enter current password for root (enter for none):
    OK, successfully used password, moving on...
    
    Setting the root password ensures that nobody can log into the MySQL
    root user without the proper authorisation.
    
    Set root password? [Y/n] y
    New password:
    Re-enter new password:
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
    
    
    By default, a MySQL installation has an anonymous user, allowing anyone
    to log into MySQL without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.
    
    Remove anonymous users? [Y/n] y
     ... Success!
    
    Normally, root should only be allowed to connect from 'localhost'.  This
    ensures that someone cannot guess at the root password from the network.
    
    Disallow root login remotely? [Y/n] n
     ... skipping.
    
    By default, MySQL comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    
    Remove test database and access to it? [Y/n] n
     ... skipping.
    
    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    
    Reload privilege tables now? [Y/n] y
     ... Success!
    
    Cleaning up...
    
    
    
    All done!  If you've completed all of the above steps, your MySQL
    installation should now be secure.
    
    Thanks for using MySQL!
    

Secure MySQL database :

    mysql> select user,host,password from mysql.user;
    +------+-----------+------------------+
    | user | host      | password         |
    +------+-----------+------------------+
    | root | localhost | 5d2e19393cc5ef67 |
    | root | CentOS57  | 5d2e19393cc5ef67 |
    | root | 127.0.0.1 | 5d2e19393cc5ef67 |
    +------+-----------+------------------+
    3 rows in set (0.00 sec)
    

Above steps is not the complete solutions to secure your production MySQL server. It just only basics how-to steps from my own experiences. I highly recommend you to read through the following article:
http://dev.mysql.com/doc/refman/5.0/en/security.html
http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html

How to Delete Anonymous Users From MySQL on CentOS 6.2

MySQL installation has a default “root” user with a blank password and an “anonymous” user, also with a blank password. This is very unsecured and not recommended. In order to protect your data, the “root” user should be set with a password and the anonymous user should be delete. In this post, i will show on how to delete Anynymous users from MySQL. Please take a look of this post if you want to “set root password for MySQL

    [root@centos6 ~]# mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 150
    Server version: 5.1.52 Source distribution
    
    Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    This software comes with ABSOLUTELY NO WARRANTY. This is free software,
    and you are welcome to modify and redistribute it under the GPL v2 license
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> select user,host,password from mysql.user;
    +---------------+-----------+-------------------------------------------+
    | user          | host      | password                                  |
    +---------------+-----------+-------------------------------------------+
    | root          | localhost |                                           |
    | root          | centos6.2 |                                           |
    | root          | 127.0.0.1 |                                           |
    |               | localhost |                                           |
    |               | centos6.2 |                                           |
    +---------------+-----------+-------------------------------------------+
    7 rows in set (0.00 sec)
    
    mysql> delete from mysql.user where user='';
    Query OK, 2 rows affected (0.00 sec)
    
    mysql> select user,host,password from mysql.user;
    +---------------+-----------+-------------------------------------------+
    | user          | host      | password                                  |
    +---------------+-----------+-------------------------------------------+
    | root          | localhost |                                           |
    | root          | centos6.2 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
    | root          | 127.0.0.1 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
    +---------------+-----------+-------------------------------------------+
    5 rows in set (0.00 sec)
    
    mysql> exit
    Bye