Reset MySQL Root Password (Use Second Method)

Reset MySQL Root Password (Use Second Method)
———————————————-

We need to reset the password now. This can be done in two ways

Method 1
———

1) Add following parameter under mysqld section in /etc/my.cnf or any other custom parameter file

[mysqld]
skip-grant-tables

2) Restart the mysql server

3) Now you should be able to login to server without password

-bash-4.1$ mysql -u root

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.67.0

Copyright (c) 2000, 2012, 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>

4) Next we need to reset the password

mysql> update mysql.user set password=password(‘root’) where user=’root’;
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

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

5) Restart the mysql server and try connecting with password

-bash-4.1$ mysql -u root -paskdba
Your MySQL connection id is 1
mysql>

This approach is widely used but has serious security concerns. This approach allows anyone to connect to mysql root user without password.
e.g I am connecting from remote machine when mysql was started with ‘skip-grant-tables’ option

-bash-4.1$ mysql -u root -h mysqldev01.askdba.org

mysql> select hostname();
ERROR 1305 (42000): FUNCTION hostname does not exist
mysql> select @@hostname;
+———————————+
| @@hostname |
+———————————+
| mysqldev01.askdba.org |
+———————————+
1 row in set (0.00 sec)

One option is to use bind-address=127.0.0.1 in my.cnf which will disable remote connections. But again this is not fool proof.

——————————————————————————————————————————————————–

Method 2
——–

This is one more way which is safer and recommended way of resetting passwords

1) Create a text file with following line say tmp_mysql.txt. Using new password to ensure that this file is read and correctly executed

update mysql.user set password=password(‘securepass’) where user=’root’;
flush privileges;

2) Edit /etc/my.cnf file and add following parameter under mysqld

[mysqld]

init-file=/home/askdba/tmp_mysql.txt

3) Restart mysql server process and you will be able to connect using specified password

bash-4.1$ mysql -u root -paskdba
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
-bash-4.1$ mysql -u root -psecurepass
mysql>

I tried with old password first to ensure that it doesn’t work. We are able to login to successfully login using “securepass” password

Advertisements

Renaming a MySQL Database

Option-1 To reduce IO use the following.
—————————————-

mysqladmin -u username -p create newdatabase
mysqldump -u username -v olddatabase -p | mysql -u username -p -D newdatabase
Option-2 Renaming a MySQL Database:
————————–

In Linux shell, use mysqldump to back up the old database, then restore the dumped database under a new name using the MySQL utility.
Finally, use the drop database command to drop the old database. This option can perform badly for large database.
mysqldump -u root -p newdb > newdb.sql
mysql -uroot -p -e “CREATE DATABASE newdb1”
mysql -uroot -p newdb1 < newdb.sql
mysql -uroot -p -e “DROP DATABASE newdb”
Option-3 Use these few simple commands
—————————–

mysqldump -u username -p -v olddatabase > olddbdump.sql
mysqladmin -u username -p create newdatabase
mysql -u username -p newdatabase < olddbdump.sql

MySQL Replication Error Solution

mysql> stop slave;
Query OK, 0 rows affected (0.01 sec)

mysql> reset slave;
Query OK, 0 rows affected (0.03 sec)

mysql> reset master;
Query OK, 0 rows affected (0.00 sec)

mysql> start slave;
Query OK, 0 rows affected (0.01 sec)
================================
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> reset slave;
Query OK, 0 rows affected (0.03 sec)

mysql> start slave;
Query OK, 0 rows affected (0.01 sec)

Backup and Restore MySQL Database

The mysqldump is a backup program used to dump a database or collection of database for a backup
Syntax: Table level
$ mysqldump [options] db_name [tbble_name …]

–Database level
$ mysqldump [options] –databases database_name …
All Databases
$ mysqldump [options] –all-databases

The mysqlimport is used to import the data into database.
Syntax:
$mysqlimport [options] db_name dumpfile1 [dumpfile2 …]

You can load the dumpfile into server using mysql command.

Backup Mysql Database using mysqldump1. Take a backup of single database on the same server
$mysqldump -u user_name -d database_name –p > database.sql

2. Backup single database from remote server
$ mysqldump -u user_name -h host_name -d database_name –p > database.sql

3. If you are running more than one MYSQL instance on different ports them you need to mention the port to backup database
$ mysqldump -u user_name -h host_name -P port -d database_name –p > database.sql

4. Backup a table from a database
$ mysqldump -u username database_name table_name > table.sql

5. Backup all databases on the server as ROOT
$ mysqldump -u root –all-databases > all_databases.sql

Restore MySQL Database using “mysql” command
If you are moving the database from one server to another server or remotely then use below commands

1. Restore a database on the same server
$mysql -u user_name database_name –p < database.sql
Or
$ mysql -e “source /tmp/database.sql ” database_name

2. Restore database from remote server
$ mysql -u user_name -h host_name database_name –p < database.sql

3. If you are running more than one MYSQL instance on different ports them you need to mention the port of Instance to restore
$ mysql -u user_name -h host_name -P port database_name –p < database.sql

4. Restore a table from a database
$ mysql -u username database_name < table.sql

5. Restore all databases from the dump as ROOT
$ mysql -u root < all_databases.sql

Restore database using mysqlimportThe database should exist in order to import dump using mysqlimport.
$ mysqlimport -u user_name -p password database_name /tmp/dumpfile.sql

Write MySQL table data to a file
Use below syntax to write table data/contents to a file
mysql> SELECT * FROM . ORDER BY DESC LIMIT 0,99000 INTO OUTFILE ‘/tmp/table_name.txt’

If you don’t have access to write from MySQL to a file then you will receive below error.
ERROR 1045 (28000): Access denied for user ‘xxxxxxx’@’%’ (using password: YES)

If you dont have permission the use below alternate option
$ echo “SELECT * FROM database_name.table_name” mysql -u -h –port= –password= > /tmp/table_name.txt

Rename Mysql Database
Either you can backup and restore the database into new database or follow below steps
mysql>create database new_database;
$ mysqldump -u user_name -d old_database -p | mysql -u user_name -d new_database -p
mysql> drop database old_database

Backup & Restore MySQL database with compression option

If your MySQL database is very large, you may like to compress the output of mysqldump.

Use the MySQL backup command below & pipe the output to gzip, then you will get the output as gzip file.

Syntax:
$ mysqldump -u [user_name] -p [password] [database_name] | gzip -9 > [backupfile.sql.gz]

If you want to extract the .gz file, issue following command:
Syntax:
$ gunzip [backupfile.sql.gz]

To restore compressed backup files, issue following command:
Syntax:
$ gunzip < [backupfile.sql.gz] | mysql -u [user_name] -p [password] [database_name]

By above article you will easily backup & restore your MySQL database with compression option.

************************************************************************
How to backup your MySQL Database[s]
************************************************************************

Backing up your database is as essential as you breathing. So please backing up your database on daily basis OR hourly basis depends on how your database contains critical/Important data.

In this article you will find easiest way to backup & restore your MySQL database.

Backing up your MySQL database using several methods like mentioned below:

1. Simple copy method:

This method is very easy to backup MySQL database, where you need to copy only binary database files.

This method may create problem & highly not recommended. For Example The multiple ways of managing case-sensitivity between Unix & Windows means that a database copied from one system to the other may become corrupt.

2. Using mysqldump command:

This is very effective tool to backup MySQL databases, While backing up, it creates text version of databases. (*.sql file)

More precisely, It create a list of SQL statements like DROP table, CREATE table and INSERT into which would be use to restore OR recreate the original database.
Using mysqldump method, you can backup a local database & restore it on a remote database at the same time, As well as you can also backup single/multiple table[s] or single/multiple database[s].

Syntax:
$ mysqldump -u [user_name] -p[password] [database_name] > [backup.sql]

user_name : Database valid user name
password : The password of your database
database_name : Name of your database to backup
backup.sql : The filename for your database backup

Let us check some practical examples on how to use mysqldump method to backup & restore:

A. Backup of Single MySQL database:

Syntax:
$ mysqldump -u [user_name] -p[password] database_name > Sinle_database_backup.sql

B. Backup of Multiple MySQL databases:

Syntax:
$ mysqldump -u [user_name] -p[password] – -databases database-I database-II > Multiple_databases_backup.sql
–databases : Mentioned this parameter when you need to backup multiple databases.

C. Backup of all MySQL databases:

Syntax:
$ mysqldump -u root -p – -all-databases > [All_database_backup.sql]

–all-databases : Mentioned this parameter when you need to backup all MySQL databases.

D. Backup single table:

Syntax:
$ mysqldump -u [user_name] -p[password] database_name table_name > Single_table_backup.sql

E. Backup multiple tables:

Syntax:
$ mysqldump -u [user_name] -p[password] database_name table-I table-II table-III > Multiple_table_backup.sql

The mysqldump command has also some other useful options like:

–add-drop-table : Tells MySQL to add a DROP TABLE statement before each CREATE TABLE in the dump.
–no-data : Dumps only the database structure, not the contents.
–add-locks : Adds the LOCK TABLES and UNLOCK TABLES statements you can see in the dump file.

The advantage of using mysqldump are that it is simple to use and it takes care of table locking issues for you.

The disadvantage is that the command locks tables. If the size of your tables is very big mysqldump can lock out users for a long period.

3. Using mysqlimport command:

Use this method to import into an already existing database (i.e. to restore a database that already exists)

Syntax:
$ mysqlimport -u [user_name] -p[password] [databasename] [backup.sql]

Restoring your MySQL database:

Above we backup database into text version of SQL file. To create/restore database you need to follow two steps:
1. Create an appropriately named database on the target machine
2. Load the file using the MySQL command:

Syntax:
$ mysql -u [user_name] -p[password] [database_name_to_restore] < [backup.sql]

By above article you will easily backup & restore your MySQL database.

***********************************************************************

Login to XE-MySQL Syntax

Login:
——
mysql -uroot -proot

# /etc/init.d/mysqld start
# /etc/init.d/mysqld stop
# /etc/init.d/mysqld restart
# mysqladmin -u root -p status
# datadir=/var/lib/mysql

mysql> show variables like ‘%datadir%;
In MySQL Space Issue: (1) Delete /var/log/mysqld.log files

———————————————————————————————————————–

Login:
——

$ sqlplus sys/oracle as sysdba

$ orapwd file =orapwXE PASSWORD=ORACLE force=y entries=3

In Oracle 11g Default path for Alter log files is:

For Issues:
———–

SQL> show parameter background_dump_dest

Ex: /u01/app/oracle/diag/rdbms/db01/db001/trace/alert_db001.log

In Oracle : (1) Delete alert log files
(2) Drop unwanted user by taking the backup using expdump and keep the backup on same server
(3) For Archive log issue, delete files from archive logs / # df -kh
SQL> archive log list;
(4) SQL DEVELOPER Connectivity issue listener
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

sqlplus system/system-password@XE

sqlplus system/system-password

sqlplus / as sysdba
Solution:

sqlplus /nolog
conn system/password
connected.
alter system register;
exit
lsnrctl stat

Now you can see the service
Even if don’t see try this one out
$ sqlplus /nolog
SQL> conn system/password
connected.
SQL> alter system set local_listener = ‘(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))’ scope = both;
… system altered …
sql> alter system register;
SQL> exit
$ lsnrctl stat (IT SHOULD SHOW SERVICE REGISTERED NOW )

This should probably work …

Installing Latest Version of MySQL on Linux (CentOS 6) Production Server

Checking if MySQL is Already Installed

[ahmed@amayem ~]$ rpm -q mysql-server
package mysql-server is not installed

Or you can do it this way:

[ahmed@amayem ~]$ yum list installed | grep mysql
[ahmed@amayem ~]$

Downloading the MySQL Yum Repository Release Package:

Choose your operating system from http://dev.mysql.com/downloads/repo/yum/
In my case it was CentOS 6, which means I would want to get EL 6. This one is 64 bit. To get the 32 bit check here:

[ahmed@amayem ~]$ wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
–2014-08-28 22:59:50– http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
Resolving dev.mysql.com… 137.254.60.11
Connecting to dev.mysql.com|137.254.60.11|:80… connected.
HTTP request sent, awaiting response… 302 Found
Location: http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm [following]
–2014-08-28 22:59:50– http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
Resolving repo.mysql.com… 23.202.216.96
Connecting to repo.mysql.com|23.202.216.96|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 5824 (5.7K) [application/x-redhat-package-manager]
Saving to: `mysql-community-release-el6-5.noarch.rpm’

100%[====================================>] 5,824 –.-K/s in 0s

2014-08-28 22:59:51 (741 MB/s) – `mysql-community-release-el6-5.noarch.rpm’ saved [5824/5824]

[ahmed@amayem ~]$ ls
mysql-community-release-el6-5.noarch.rpm

We have the rpm.
Installing the MySQL Yum Repository Release Package

Now that we have the release package, it’s time to install it:

[ahmed@amayem ~]$ sudo yum localinstall mysql-community-release-el6-5.noarch.rpm

There will be quite a bit of output, and there should be a prompt that looks something like the following:

Total size: 4.3 k
Installed size: 4.3 k
Is this ok [y/N]:

Of course accept with y or Y. Some more output will be displayed, which should end with something like the following:

Installed:
mysql-community-release.noarch 0:el6-5

Complete!

Checking the Version of the Available Mysql

[ahmed@amayem ~]$ yum info mysql-community-server

You will see quite a bit of output that I have truncated, but in the end the relative info should be displayed:

Available Packages
Name : mysql-server
Arch : i686
Version : 5.1.73
Release : 3.el6_5
Size : 8.8 M
Repo : updates
Summary : The MySQL server and related files
URL : http://www.mysql.com
License : GPLv2 with exceptions
Available Packages
Name : mysql-community-server
Arch : i686
Version : 5.6.20
Release : 4.el6
Size : 51 M
Repo : mysql56-community
Summary : A very fast and reliable SQL database server
URL : http://www.mysql.com/
License : Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Under GPLv2 license as shown in the Description field.

Notice that there are two packages:

mysql-server
mysql-community-server

mysql-server is the one provided by the default yum repositories. mysql-community-server is the one provided by our newly installed MySQL yum repository, which should be the latest stable release. To install any other version check here.
Installing

If you are happy with the version then it’s time to install:

[ahmed@amayem ~]$ yum install mysql-community-server
Loaded plugins: fastestmirror
You need to be root to perform this command.

Oops we need to use sudo. Check here to see how to give a linux user sudo powers:

[ahmed@amayem ~]$ sudo yum install mysql-community-server

There will be quite a bit of output, and there should be a prompt that looks something like the following:

Total download size: 70 M
Installed size: 292 M
Is this ok [y/N]:

Of course accept with y or Y. Some more output will be displayed followed by another prompt that looks like the following:

warning: rpmts_HdrFromFdno: V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : MySQL Release Engineering <mysql-build@oss.oracle.com>
Package: mysql-community-release-el6-5.noarch (@/mysql-community-release-el6-5.noarch)
From : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]:

This is just a way to check that what has been downloaded so far has not been corrupted. Accept with y or Y. The tests should succeed. The output should end with the following:

Complete!

Starting MySQL

[ahmed@amayem ~]$ sudo service mysqld start
Initializing MySQL database:

There is more output that I have truncated. It should end with something like this:

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 amayem.amayem.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.

Please report any problems at http://bugs.mysql.com/

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

Note: new default config file not created.
Please make sure your config file is current

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
–defaults-file argument to mysqld_safe when starting the server

[ OK ]
Starting mysqld: [ OK ]

Securing the Installation

As mentioned in the above output, if we are running this on a production server then we should do a secure installation as follows:

[ahmed@amayem ~]$ 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):

This should be the first time, so we shouldn’t have a password yet. Just press enter.

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]

Enter Y and enter your new password:

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]

If you are running on a production server then you should definetely press Y.

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]

Once again if you are in production then enter Y. In fact enter Y for all the questions if you are in production:

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…
ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist
… Failed! Not critical, keep moving…
– 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!
All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.

Congratulations you are done. Now let’s see if mysql will survive a reboot:
Surviving a reboot

First let’s check that it is running:

[ahmed@amayem ~]$ ps -e | grep mysql
683 pts/0 00:00:00 mysqld_safe
887 pts/0 00:00:00 mysqld

That looks right. Alternatively:

[ahmed@amayem ~]$ sudo service mysqld status
mysqld (pid 887) is running…

Now let’s reboot and see if we get the same thing:

[ahmed@amayem ~]$ sudo reboot

Wait a bit then login again, and repeat the above:

[ahmed@amayem ~]$ sudo service mysqld status
mysqld is stopped

So it does not automatically run on reboot. We need to setup the init.d script:

[ahmed@amayem ~]$ cd /etc/init.d/

We should see a mysqld file, that was put there with the install:

[ahmed@amayem init.d]$ ls | grep mysql
mysqld

The script is there but is it being used?

[ahmed@amayem init.d]$ chkconfig –list | grep mysql
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off

It’s off for everything. Let’s turn it on for level 3:

[ahmed@amayem init.d]$ sudo chkconfig –level 3 mysqld on
[ahmed@amayem init.d]$ chkconfig –list | grep mysql
mysqld 0:off 1:off 2:off 3:on 4:off 5:off 6:off
[ahmed@amayem init.d]$

Now let’s reboot again and test:

[ahmed@amayem init.d]$ sudo service mysqld status
mysqld is stopped
[ahmed@amayem init.d]$ sudo service mysqld start
Starting mysqld: [ OK ]
[ahmed@amayem init.d]$ sudo service mysqld status
mysqld (pid 1159) is running…
[ahmed@amayem init.d]$ sudo reboot
[ahmed@amayem init.d]$
Broadcast message from ahmed@amayem.amayem.com
(/dev/pts/1) at 1:17 …

Now let’s test:

[ahmed@amayem ~]$ sudo service mysqld status
mysqld (pid 733) is running…

Installing & Configuring MySQL Server

# yum install mysql mysql-server

(or)
rpm recommended method (of particular version)
i.e; rpm of client and rpm of server

Start MySQL server daemon (mysqld):

To restart, start or stop MySQL server from the command line
————————————————————-
/etc/init.d/mysqld status

/etc/init.d/mysqld start

/etc/init.d/mysqld stop

/etc/init.d/mysqld restart

—–(At Last if nothing works for starting MySQL) You can start the MySQL daemon with:——-
Running and Shutting down MySQL Server:
—————————————————————————————————————-

First check if your MySQL server is running or not.

ps -ef | grep mysqld

If your MySql is running, then you will see mysqld process listed out in your result.
If server is not running, then you can start it by using the following command:

root@host# cd /usr/bin
./safe_mysqld &

Now, if you want to shut down an already running MySQL server, then you can do it by using the following command:

root@host# cd /usr/bin
./mysqladmin -u root -p shutdown
Enter password: ******

–Setting New Root Password–

/usr/bin/mysqladmin -u root password ‘new-password’
/usr/bin/mysqladmin -u root -h angstrom password ‘new-password’
Starting MySQL:

Login as root database admin to MySQL server:

# mysql -u root
password:

mysql>
Delete ALL users who are not root:

mysql> delete from mysql.user where not (host=”localhost” and user=”root”);

mysql> FLUSH PRIVILEGES;

Change root database admin password: (note: once this step is complete you’ll need to login with: mysql -p -u root)

mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘mypass’);

mysql> FLUSH PRIVILEGES;

How to reset your root MySQL password

Stop the MySQL process

# service mysqld stop

Once MySQL has stopped, restart it with the –skip-grant-tables option
# mysqld_safe –skip-grant-tables &
or edit your /etc/my.cnf file to add the line
skip-grant-tables

Connect to MySQL using the root user.
mysql -u root

Once logged in, you should see the following prompt:
mysql>
Enter the following commands:
mysql> use mysql;
mysql> UPDATE user SET password=PASSWORD(“YOUR NEW PASSWORD HERE”) WHERE User=’root’;
mysql> flush privileges;
mysql> quit

Now stop MySQL again:
# service mysqld stop

If you edited your /etc/my.cnf file, delelete the skip-grant-tables line.

Now restart MySQL and test your new login.
# service mysqld restart
# mysql -u root -p
Ref:http://www.codero.com/knowledge-base/questions/296/How+to+reset+your+root+MySQL+password

How to install/uninstall/upgrade rpm package with/without dependencies

A RPM package abbreviated as Red Hat Package Manager refers to Red Hat package installed on Fedora, CentOS, OEL and all Red Hat source code derived OS.

To know more about a rpm package click on the below link
Understanding RPM package

Installing from the downloaded rpm package
Use -ivh switch along with rpm command as shown below

# cd /root/rpms
# rpm -ivh cvs-1.11.23-16.el6.i686.rpm
Preparing… ########################################### [100%]
1:cvs ########################################### [100%]
Installing directly from the package available on web.
But for this you need to have the proper link of the rpm you want to download or install

# rpm -ivh ftp://ftp.pbone.net/mirror/ftp.centos.org/6.5/os/i386/Packages/cvs-1.11.23-16.el6.i686.rpm
Retrieving ftp://ftp.pbone.net/mirror/ftp.centos.org/6.5/os/i386/Packages/cvs-1.11.23-16.el6.i686.rpm
warning: /var/tmp/rpm-tmp.z3VsTc: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing… ########################################### [100%]
1:cvs ########################################### [100%]
Installing a package forcefully without dependencies
Use –force argument along with -ivh switch as shown below to install forcefully without dependencies

# rpm -ivh vsftpd-2.2.2-11.el6_4.1.i686.rpm –force
warning: vsftpd-2.2.2-11.el6_4.1.i686.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing… ########################################### [100%]
1:vsftpd ########################################### [100%]
Upgrading a package
Use -Uvh switch along with rpm command
# rpm -q vsftpd
vsftpd-2.0.5-28.el5.i386
# rpm -Uvh vsftpd-2.2.2-11.el6_4.1.i686.rpm
warning: vsftpd-2.2.2-11.el6_4.1.i686.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing… ########################################### [100%]
1:vsftpd ########################################### [100%]

Removing a package
You can uninstall a package using -e switch along with rpm command
NOTE: Before removing a package make sure you get the complete name of the package using the below command
# rpm -qa | grep cvs
cvs-1.11.23-16.el6.i686
# rpm -e cvs-1.11.23-16.el6.i686

Removing a package without dependencies
Use an extra argument –nodeps along with rpm command to remove/uninstall a package without dependencies

# rpm -e vsftpd-2.2.2-11.el6_4.1.i686 –nodeps