MySQL Database

How To Setup MySQL Replication

In this tutorial, I will provide step by step process to setup MySQL replication. We will create one master and one slave. We will use two CentOS 6 servers - one for master and the other for slave. This following steps have been tested on two virtual machines.

Our master server will have IP address
Our slave server will have IP address

You might want to run SELinux in permissive mode.

Perform these steps on the master:

Install MySQL server.

yum install mysql-server -y

Changes In Bizsense

Bizsense is an open source CRM project which uses Zend Framework. The open source project was started by Binary Vibes about three years ago and was released under the GPL V3 license. Some of you might have noticed that I am no longer active in Binary Vibes.

I wanted Bizsense project development to continue to nourish, flourish and cherish. Therefore, there we did a few changes. Bizsense is now released under the new BSD license. Bizsense uses Google open source project hosting which offers issue tracker, Wiki and source control. Bizsense now uses Mercurial for source control. The documentation is published at In order to contribute to Bizsense, signing a CLA is no longer required.

Here are the project links:

Installing Redmine With MySQL And Nginx On CentOS 6

Redmine is a software project management tool which has Wiki, issue tracer, source code browser and other cool features built in. If you want to install Redmine with MySQL and Nginx on CentOS 6, follow these steps.

I always use EPEL repository with CentOS. EPEL provides additional RPM packages. We can use Nginx and some Ruby gem packages from EPEL.

Enable EPEL:

rpm -Uvh

Install required packages:

yum install nginx mysql-server ruby rubygem-rack rubygem-rake ruby-mysql

Redmine requires a Ruby gem called i18n. I couldn't find the RPM for i18n gem. I had to install i18n gem using the gem installer.

gem install -v=0.4.2 i18n

Start MySQL server:

/etc/init.d/mysqld start

Use the MySQL secure installation program:


Connect to the MySQL server as root:

mysql -u root -p

Create a MySQL database and user for Redmine:
mysql> CREATE DATABASE redmine character set utf8;
mysql> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost' IDENTIFIED BY 'secret_password' WITH GRANT OPTION;

Enable MySQL General Query And Slow Query Log

MySQL has a query logging feature. In order to use it you have to first enable it.

Enabling the general query log

Step 1: Set your log file in /etc/my.cnf

vi /etc/my.cnf

In the [mysqld] section specify the general log file name:


Step 2: Create the file and make sure it is owned by the system user mysql

touch /var/log/mysqld.general.log
chown mysql.mysql /var/log/mysqld.general.lo
Taxonomy upgrade extras: 

Setting Up MySQL - Database, Users And Sample Table

We discussed how to install LAMP in one of our previous articles. Some of you may be wondering how to create databases, users and tables on your newly installed MySQL server. This blog post introduces the preliminary steps to work with your new LAMP server.

We are going to learn the following:

  • Changing MySQL user password
  • Creating databases
  • Deleting databases
  • Creating MySQL user accounts
  • Deleting MySQL user accounts
  • Connecting to the MySQL server from the command line
Taxonomy upgrade extras: 

Tip Of The Day : Use A Data Generator

While developing applications creating test data can be a tedious process to the developers. You don't have to do the same things like creating a user for testing over and over again.

Use a data generator. There are numerous tools freely available online that can provide the test data for you.

Taxonomy upgrade extras: 

Exporting MySQL Data To CSV In PHP

Do you want to export data stored in a MySQL database to CSV file?

The solution is damn easy if you already know how to connect to MySQL database and read or display data from a PHP script. Let's start working on it.

Let us first create a sample table. In our example scenario, let us create a table to store contact information.

CREATE TABLE `contacts` (
`first_name` VARCHAR( 50 ) NOT NULL ,
`middle_name` VARCHAR( 50 ) NOT NULL ,
`last_name` VARCHAR( 50 ) NOT NULL ,
`email` VARCHAR( 320 ) NOT NULL ,
`phone` VARCHAR( 20 ) NOT NULL

Taxonomy upgrade extras: 

Moving MySQL Database To A Different Computer

Moving MySQL Database To A Different Computer AKA Backup And Restore

Many popular web applications are written in PHP and use MySQL database. In this post I will describe, how you can move your database to a different computer. Almost all web applications store database and files system information in configuration files. You can actually move your web application to a different server without much hassle by editing few lines in these configuration files. I will write more about the configuration files of web applications in a different post. In this post I will walk you through the steps to move your MySQL database to a different server. The commands will help you move both data and schema.

What do you need to know before moving a database? On both the computers you will require the

  • MySQL database name
  • MySQL username that has access to the database
  • Password for the username that has access to database

You can take a backup of your database in the form of SQL dump and restore it on another server quickly from the Shell. Later in the post we will discuss how you can import and export MySQL databases using a graphical tool.

Launch the terminal. If the server is accessible remotely using SSH you can execute these commands on the secure shell.

Command 1 to generate the backup

mysqldump -u mydatabaseuser -p mydatabase > backup.sql
Taxonomy upgrade extras: