Search This Blog

Friday, January 13, 2012

How to connect mysql to Matlab

Today i will post how to connect mysql database to Matlab

download mysql database from here click here

after installing mysql software, we have to install mysql driver for connecting mysql to matlab click here to download

Now open your mysql software and create database eg Naik


Steps used in mysql
When you open mysql it will ask password
In my eg mysql data base password is naikgroup
Step 1
%create database naik
Create database naik
Step 2
%use database
Use naik
Step 3
%exit from mysql

Now you can connect mysql to Matlab follow this steps

1. Go to control panel -> Administrative Tools (Change view to Small icons)
2. Click on Data Sources(ODBC)
3. ODBC Data Source Administrator window will open, Select Add

4. Select MySQL Driver

Data Source Name
Use any Name in Data Source Name

Description is optional

user: root
password : use your mysql password
in my eg password is naikgroup

Database which on you create in mysql
in my eg database is naik

Now click on test to check connection between mysql and matlab


Follow these commands in matlab to connect mysql to matlab
We create database called naik
I used mysql password as naikgeoup
conn = database('datasourcename','username','password')
conn = database('datasourcename','username','password') connects a MATLAB software session to a database via an ODBC driver and assigns the returned connection object to conn. The arguments passed to this function are as follows:
• datasourcename: The data source to which you connect.
• username and password are the user name and password required to connect to the database. If a user name or password are not required to connect to your database, specify empty strings for these arguments.
In our case it will be
conn = database('test','root','naikgroup')

now you can able to store data from matlab to mysql

hope this post help you...
feel free to comment and don`t forget tell thanks...!!!

Related Posts :-
GUI Code for capture image - Matlab
how to run m file in gui using matlab
Matlab code for shutdown computer
How to see webcam preview in Matlab
How to capture image form webcam in Matlab
How to connect microsoft access to Matlab
How to install matlab 2007 on Windows7