MySQL is most popular Open Source Data Base Server. MySql is RDBMS ( Relational Database Management System. it provides multi user access to the number of databases.

Step-1 : Installation of MySql Server using yum.

`
[root@dbase1 /]#  yum install mysql mysql-server php-mysql

Step-2 : Start mysql service.

 

 

[root@dbase1 /]# service mysqld start

Output

Initializing MySQL database:  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 dbase1.broexperts.com 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 /usr/mysql-test ; perl mysql-test-run.pl

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

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

Step-3 : Secure Mysql server. By default passwords are undefined.
in order to make secure we need to set password of root and also block anonymous access.

[root@dbase1 /]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.61 Source distribution

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>

Now we logged in to mysql.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.03 sec)

Output show by default mysql creates 3 databases.

Step-4 : select ‘mysql’ database

mysql> use mysql

show users & passwords

mysql> select user,host,password from user;

Output

+------+-----------------------+----------+
| user | host                  | password |
+------+-----------------------+----------+
| root | localhost             |          |
| root | dbase1.broexperts.com |          |
| root | 127.0.0.1             |          |
|      | localhost             |          |
|      | dbase1.broexperts.com |          |
+------+-----------------------+----------+
5 rows in set (0.00 sec)

Output shows 5 users but if you look in the ‘password’ field its blank means passwords are undefined.
Step-5 : Set Passwords.

mysql> set password for 'root'@'dbase1.broexperts.com'= password ('redhat');
mysql> set password for 'root'@'localhost'= password ('redhat');
mysql> set password for 'root'@'127.0.0.1'= password ('redhat');

Verify changes

mysql> select user,host,password from user;
+------+-----------------------+-------------------------------------------+
| user | host                  | password                                  |
+------+-----------------------+-------------------------------------------+
| root | localhost             | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
| root | dbase1.broexperts.com | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
| root | 127.0.0.1             | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
|      | localhost             |                                           |
|      | dbase1.broexperts.com |                                           |
+------+-----------------------+-------------------------------------------+
5 rows in set (0.00 sec)

Note : According to output there is still two Anonymous users exist without passwords.

Step-6 : Delete anonymous Users.

mysql> DELETE FROM mysql.user WHERE user = '  ';
Query OK, 2 rows affected (0.00 sec)

Step-7 : Run ‘flush privileges’ command.

mysql>; flush privileges;
Query OK, 0 rows affected (0.00 sec)

verify changes

mysql> select user,host,password from user;
+------+-----------------------+-------------------------------------------+
| user | host                  | password                                  |
+------+-----------------------+-------------------------------------------+
| root | localhost             | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
| root | dbase1.broexperts.com | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
| root | 127.0.0.1             | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
+------+-----------------------+-------------------------------------------+
3 rows in set (0.00 sec)

Now output shows we have 3 users and all secured with password.

Similar Posts