MySQL: Duplicate MySQL database

One of the client are requesting to duplicate their database to development database in case their production database have change mistakenly.

– MySQL Database server
– Root password: [email protected]
– Production Database: db1
– Development Database: db2
– Development User: db_user
– Development User Password: [email protected]

To do this, I choose to use mysqldump to done it.

1. First of all, you must create the development database named db2.

mysql -u root -p'[email protected]' -e "create database db2"

2. Next, you may duplicate the database data from db1 to db2.

mysqldump -u root -p'[email protected]' db1 | mysql -u root -p'[email protected]' db2

3. Now, you need to assign the MySQL user permission to the db2(development) database.
a) Log into the database server.

mysql -u root -p'[email protected]'

b) Grant the database privilege,

mysql> GRANT ALL PRIVILEGES ON db2.* TO [email protected] ;

Could not find gem rack locally or in a repository

I was trying to install Ruby on Rails Gem and it is failed with error of “could not find gem rack locally or in a repository”.

[email protected] [~]# gem install rack
ERROR:  could not find gem rack locally or in a repository

I did try to overcome the issue and found out there are two solutions for it.

Solution 1:
Change the gem source.

To show the gem source installed in the server,
[email protected] [~]# gem source

1. Change the gem source to allow
[email protected] [~]# gem sources -a added to sources

2. Check the gem source again and it is added.
3. Install your gem again.
[email protected] [~]# gem install rack

Solution 2:
Download the Gem source to your server and install it locally and let say I am referring to rack gems.

Download the source file from URL below.

[email protected] [~]# wget
[email protected] [~]# tar zxf rack-1.2.0.tar.gz
[email protected] [~]# gem install rack


Change MySQL Collation

Sometimes, the MySQL database collation could make your web content become question mark(?) and you might not know what is happening and what wrong from your scripting.

To understand what is the server default collation, there are two ways to done it as below.

[email protected] [~]# mysqladmin variables | grep collation
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |


Login to MySQL from server.

[email protected] [~]# mysql -uroot -p
mysql> SHOW VARIABLES LIKE ‘collation%’;
| Variable_name | Value |
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
3 rows in set (0.00 sec)

With the above command, you will notice that the collation set from your server is utf8_general_ci. Assume that you wish to change them to latin1_general_ci, simply edit your /etc/my.cnf (Linux) or C:\MySQL5\my.ini file record from




But please aware that you should not simply change the collation as it might affected some of your database data become question mark(?).

Then you shall restart the MySQL services.