About Me

My photo
Hi Friends, I am Sandeep CC and some people know me as System Administrator. I have started my professional career from 2008. I have been working as System Administrator on Linux Server and Windows Client. I am here to share my Knowledge in which I have experienced and which I have come across till now, It could be help to you people. In case anything wrong or any improvements in my post steps, Please comment to the post, Feel free to contact me by posting comments on this blog. Thanks and Regards, Sandeep CC

Monday, March 29, 2010


Configuration Mysql on Redhat Linux4.


Server: sandeeplinux3 ( Local Network IP)


mysqlclient10-3.23.58-4.RHEL4.1 (default installed)
mysql-4.1.12-3.RHEL4.1 (default installed)
mysql-server-4.1.12-3.RHEL4.1 (Need to install)
mysql-4.1.12-3.RHEL4.1 (default installed)
perl-DBD-MySQL-2.9004-3.1 (Need to install)

Download Required Packages From RHEL4 CD:
(All packages are available on 4th CD)
[root@sandeeplinux3 ~]# cd /media/cdrecorder/
[root@sandeeplinux3 cdrecorder]#
[root@sandeeplinux3 RPMS]# ls -ltr mysql-server*
-rw-r--r-- 210 root root 2967401 Sep 13 2005 mysql-server-4.1.12-3.RHEL4.1.x86_64.rpm
[root@sandeeplinux3 RPMS]# cp mysql-server-4.1.12-3.RHEL4.1.x86_64.rpm /root/IMP_rpm_packages/
[root@sandeeplinux3 RPMS]# ls -ltr perl-DBD*
[root@sandeeplinux3 RPMS]# cp perl-DBD-MySQL-2.9004-3.1.x86_64.rpm /root/IMP_rpm_packages/
[root@sandeeplinux3 RPMS]# cd
[root@sandeeplinux3 ~]#

Note: Need to Install 1st DBD-MySQL package or else while installing mysql-server package it will give warn massage/error, so need to install must DBD-MySQL package before mysql-server.

Installation Of Required Packages:
[root@sandeeplinux3 IMP_rpm_packages]# rpm -i perl-DBD-MySQL-2.9004-3.1.x86_64.rpm
warning: perl-DBD-MySQL-2.9004-3.1.x86_64.rpm: V3 DSA signature: NOKEY, key ID db42a60e
[root@sandeeplinux3 IMP_rpm_packages]# rpm -i mysql-server-4.1.12-3.RHEL4.1.x86_64.rpm
warning: mysql-server-4.1.12-3.RHEL4.1.x86_64.rpm: V3 DSA signature: NOKEY, key ID db42a60e
[root@sandeeplinux3 IMP_rpm_packages]#

Start Services:
[root@sandeeplinux3 IMP_rpm_packages]# chkconfig mysqld on
[root@sandeeplinux3 IMP_rpm_packages]# service mysqld start
Initializing MySQL database: [ OK ]
Starting MySQL: [ OK ]
[root@sandeeplinux3 ~]# service mysqld status
mysqld (pid 2677) is running...
[root@sandeeplinux3 ~]#

Creating Mysql Root Account & Password for 1st time:
[root@sandeeplinux3 ~] # mysqladmin -u root password

Restore root password On Mysql (In case of forgot the password or misplaced):
[root@sandeeplinux3 ~]# service mysqld stop
Stopping MySQL: [ OK ]

[root@sandeeplinux3 ~]# mysqld_safe --skip-grant-tables --skip-networking &
[1] 3912
[root@sandeeplinux3 ~]# Starting mysqld daemon with databases from /var/lib/mysql

[root@sandeeplinux3 ~]# mysql -u root [In safe mode enter without password as root account)

mysql> use mysql

mysql> UPDATE user SET Password=PASSWORD("newpassword") WHERE User="root";

mysql> exit

[root@sandeeplinux3 ~]# service mysqld restart
STOPPING server from pid file /var/run/mysqld/mysqld.pid
100311 12:05:05 mysqld ended

Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
[1]+ Done mysqld_safe --skip-grant-tables –skip-networking

[root@sandeeplinux3 ~]# mysql -u root -p
Enter password: (Give New Password)

Change/Update the Mysql root Password:
[root@sandeeplinux3 ~]# mysqladmin -u root -p'oldpassword' password newpassword

Change Mysql Password for Users:
[root@sandeeplinux3 ~]# mysqladmin -u xyz -p'oldpassword' password newpassword
Create Normal Users: (Create user for particular one database)
mysql> grant all privileges on .* to username@"localhost" identified by 'password';
Query OK, 0 rows affected (0.00 sec)
CREATE USER 'nisnfs'@'localhost' IDENTIFIED BY 'password';
Give all database permission to particular user:
mysql> grant all privileges on *.* to nisnfs@"localhost" identified by 'nisnfs123';
Query OK, 0 rows affected (0.00 sec) [we can give this permission to already created users or while creating new users]

Example Of Creating One Database:

[root@sandeeplinux3 ~]# mysql -u root -p [login as root or normal user & give password]
Enter password:

mysql> create database sandeep_system_information; [Create database name on sandeep_system_information]

mysql> show databases; [Check created database]
| Database |
| sandeep_system_information |
| mysql |
| test |
3 rows in set (0.00 sec)

mysql> use sandeep_system_information; [Select created database]
Database changed

mysql> create table Hardware_Information (Processor char(50),Harddisk char(50),RAM char(25),Optical_Drive char(25),Screen char(25),Keyboard char(25),Mouse char(25),UPS char(25),Wireless_Adapter char(25));
Query OK, 0 rows affected (0.00 sec) [Create Table as Hardware_Information]

mysql> show tables; [Check created table]
| Tables_in_sandeep_system_information |
| Hardware_Information |
1 row in set (0.00 sec)
mysql>crate table Hardware_Information (SL int(10),Name char(10),Remark char(10));
Query OK, 1 row affected (0.00 sec) [Create some coloms in table]
mysql>insert into Hardware_Information ('1','monitor','good'); [feel some value in rows by columns]
mysql> select * from Hardware_Information; [Show filled rows and columns]
mysql> exit [come out from sql server]
mysql> drop database sandeep_system_information; [Delete database name on sandeep_system_information]

Firewall With Mysql:
Edit iptables file for enable 3306 port
[root@sandeeplinux3 ~]# vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -s -d -p tcp --dport 3306 -j ACCEPT
-A RH-Firewall-1-INPUT -s -d -p udp --dport 3306 -j ACCEPT

No comments:

Post a Comment