MATLAB Connect to SQL database

Source: Internet
Author: User
Tags management studio microsoft sql server management studio sql server management sql server management studio

Recent projects also involve the MATLAB connection database, below I will record how to configure so that MATLAB can connect to the SQL database. As a result of recent projects to do more, so share are in the project configuration, the original for these configurations but repeated unloading and reloading, the algorithm actually has, but now there is no time to collate, will continue to record the search process we used and the algorithm involved in the search.

First of all, let me explain that my operating system is WIN8, the database used is SQLSERVER2012, the use of MATLAB is 2012a. In the installation of the above software, in my experience is to install SQL2012 first (not necessarily), because when I first loaded VS2010, it will bring a SQL, this will be a problem, the ODBC driver version of SQL will be 6.01 (possible). And then use MATLAB2012A to connect to the database when the error, the reason is the ODBC driver problem. So the order of installation is to install the SQL2012 first, then the VS and MATLAB installation order is not affected. If the SQL2012 is installed first, then the ODBC driver version will be 6.03, this time with the database function of MATLAB to connect the databases when the error will not be. When the software is installed, I record the specific connection process below.

1. View services (if there is a database conflict)

Right click on My Computer---management services and applications--services, in the right side of the interface can find two services,

In fact, these two services sometimes conflict, so I can choose to turn off SQLExpress this service, and then keep MSSQLServer.

2. Database creation

Open Microsoft SQL Server Management Studio, use window validation to log in, and create a new database named MyDB under the database. If you want to create a user for it, you can follow the procedure below: expand Security-Right-click Login-New login name

Then enter the user name and password as follows, and note that the "User must change password at next logon"

Then tick the following two items in the user mapping, not all of them, where db_denydatareader,db_denydatawriter is forbidden to read and write to the user.

It is best to right-click on the server, select Security, and modify the server authentication mode to SQL Server and Windows ID authentication.

3. Create a data source

To set up the data source, you can refer to this article:

Http://wenku.baidu.com/link?url= Ntwxb-xc4sswb024mdak8tue6npefsunjazfoldzhlezrup0-2mvnb3lgebkgsdknpumwqgqozf86b2ma1suytkr459xl9bhkr4jd8plnik

But I have a slightly different. Open Control Panel, administrative Tools->ODBC data source (64-bit) and you will see such as:

Click Add, select Data source driver is SQL server-> by completion:

Name your database (assuming I'm mydb), and then enter (local) in the server. , then click Next and then click Next to test if you can connect:

If you are able to connect, you will see and then choose the next step until you are done, and the data source is set up:

If configured well, you can finally open matlab, in MATLAB input database (' mydb ', ', ') can see the following information:

MATLAB Connect to SQL database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.