This post has already been read 9453 times!

1. Install Java

Liquibase 3.x requires Java 1.6+ so lets get that installed first

$ sudo yum install java-1.7.0-openjdk

2. Get the Liquibase Code

I'm just going to install put Liquibase in the home directory for now

$ wget
$ tar zxvf liquibase-3.1.1-bin.tar.gz
$ sudo chmod + x ./liquibase
$ ./liquibase --version

3. Install MySQL

$ sudo yum install mysql mysql-server
$ sudo chkconfig --levels 235 mysqld on
$ sudo service mysqld start
$ /usr/bin/mysqladmin -u root password 'root'
$ mysql -u root -p root

4. Install the MySQL connector for Java

$ wget
$ tar zxvf mysql-connector-java-5.1.30.tar.gz

5. Create the MySQL database

$ mysql -uroot -proot
mysql> create database example;
mysql> exit;

6. Create a Changelog file

$ vim ./changelog.xml

Add the following...

 <?xml version="1.0" encoding="UTF-8"?>  
   <changeSet id="1" author="bob">  
     <createTable tableName="department">  
       <column name="id" type="int">  
         <constraints primaryKey="true" nullable="false"/>  
       <column name="name" type="varchar(50)">  
         <constraints nullable="false"/>  
       <column name="active" type="boolean" defaultValueBoolean="true"/>  

7. Run Liquibase

$ ./liquibase --driver=com.mysql.jdbc.Driver --classpath=mysql-connector-java-5.1.30/mysql-connector-java-5.1.30-bin.jar  --changeLogFile=changelog.xml --url="jdbc:mysql://localhost/example" --username=root --password=root update

8. Create a file

$ vim ~/

Add the following...

 driver: com.mysql.jdbc.Driver  
 classpath: mysql-connector-java-5.1.30/mysql-connector-java-5.1.30-bin.jar  
 url: jdbc:mysql://localhost/example  
 username: root  
 password: root  

9. Run Liquibase with the properties file

$ ./liquibase --changeLogFile=changelog.xml update

Leave a Reply

Post Navigation