logo-mysql-heure-date

Convert timestamp to Date readable format in MySQL query

SQL query to convert timestamp to date readable format, which is stored in MySQL database.

SELECT t.*, DATE_FORMAT(FROM_UNIXTIME(t.enteredOn), ‘%e %b %Y’) AS formated_date FROM tbl_sample AS t;

For the detailed reference on DATE_FORMAT() and FROM_UNIXTIME()

Read More

Export all procedures alone from mysql via terminal

This is a easiest way to export all procedures alone from specified database through Terminal. Using mysqldump we can do this. General syntax of the command is as follows,

After enter the command in Terminal press ENTER, then the Terminal will prompt to enter database password where you have to provide the database password. Then you can check the path which you specified to save the .sql file. In the specified path you can see the export file.

Read More

Connecting mysql server via terminal

We all know that there is GUI available to connect MYSQL server (phpmyadmin). Most of the developers are not aware about connecting MYSQL server via terminal. Here we are going to explain how to connect a MYSQL server (both local & remote) via terminal.

 

After enter the above command, press ENTER. Then the Terminal will prompt to enter the password to connect. If you given valid credentials, then the terminal will display the shell pointer as mysql>

Once the connection established you can manipulate the database using SQL commands.

Read More

Allow remote connections to mysql server

Here, we are going to discuss about allowing remote connections to our local MYSQL server. To do this just edit the MYSQL server configuration file my.cnf which you can found in /etc/mysql/my.cnf (Ubuntu 12.04). Check for the configuration variable called bind-address. Just comment that line by using # and then restart the MYSQL server. These steps you can do via Terminal. See below for more details:

i) Open your terminal

ii) Type sudo gedit  /etc/mysql/my.cnf and hit the ENTER

iii) Comment the bind-address line as discussed above

iv) Restart MYSQL server by typing the command sudo /etc/init.d/mysql restart. Hit the ENTER.

Once you have completed the above steps, check the remote connection to the MYSQL server.

Read More

Sesame installation with PHP in Ubuntu

Before going to installation process, we can understand what is RDF, SPARQL, SESAME etc…

RDF stands for Resource Description Framework. It is used for conceptual description or modeling of information that is implemented in web resources, using a variety of syntax formats [more].

SPARQL is a query language for RDF.  Using this we can manipulate, store and retrieve data which is stored in RDF. This standard was introduced by RDF data access working group of the w3c [more].

SESAME is a de-facto standard framework for processing RDF data [more].

Since OpenRdf.org providing SDK which is a Java based interface, we need to configure Tomcat (version 6 or higher) on our system. Steps to install Tomcat web server is:

i. Ensure that the you already installed Java

ii. Open the terminal

iii. Run the following commands

sudo apt-get update

sudo apt-get install tomcat6

Then download the SDK provided by openrdf.org [download link]. Go to the location where you are downloaded the SDK. Extract the downloaded SDK. You can see both Sesame server and OpenRdf workbench files inside the extracted folder. Open the war folder. You have to deploy those war-files inside Java Servlet Container (like Apache Tomcat 6 web server). By deploying means nothing but copying the war files found inside the extracted folder to the Java Servlet Container (tomcat6 web path. Most probably the path will be /var/lib/tomcat6/webapps).  Then take the following URL in your browser: http://<your servername>:8080/openrdf-sesame.

After that you have given full permission to the .aduna folder which you can found in the path /usr/share/tomcat6. Since we are using MYSQL as back end, we need to download the JDBC driver which will make the communication between the Sesame Workbench and MYSQL database. To download the MYSQL JDBC driver click here.  Copy the jar file from the downloaded JDBC driver and paste in to the WEB-INF/lib folder which you can see in the web application path (both /var/lib/tomcat6/webapps/openrdf-sesame/WEB-INF/lib/var/lib/tomcat6/webapps/openrdf-workbench/WEB-INF/lib).

If you have done this much work successfully, you are almost installed the Sesame Workbench in your machine. You can manage your Sesame Workbench through both http://<your servername>:8080/openrdf-sesame & http://<your servername>:8080/openrdf-workbench.

Note: If you are using MYSQL as back-end, sometimes the Workbench will crash if we haven’t properly shutdown the service of tomcat6 web server. That time just delete the locked table which you can see in the database where RDBMS repository created.

Read More