Data Analysis System DIY2/3: Local 64-bit WIN7 + dev c ++ compiler for VMware CentOS7 + MariaDB, diy2win7

Source: Internet
Author: User
Tags centos server heidisql

Data Analysis System DIY2/3: Local 64-bit WIN7 + dev c ++ compiler for VMware CentOS7 + MariaDB, diy2win7

Three tasks to be completed in DIY data analysis system.

1. Use VMware to install 64-bit CentOS. The database server can use the built-in CentOS.

2. Data collection and pre-processing are programmed using Dev-C ++.

3. Use MATLAB R2012b on local Win7 64 to connect to the database for mining and analysis.


This document describes how to complete the second task.


1. Enter the command line "ifconfig" in Terminal to confirm that the ip address of the CentOS virtual machine is 192.168.124.128.

2. Enter the command line "netstat-anp | grep mysqld" to confirm that the mariadb service listening port is 3306.

3. Use HeidiSQL for local installation in Win7 to test whether the connection can be established. (HediSQL is a graphical interface management software provided by mariadb for windows. You can install it when installing mariadb)

Enable HeidiSQL and session settings


Click "open" to report connection failure

4. The possible cause is that mariadb's remote access permission is not granted.

Terminal login mariadb "mysql-u root-p", enter the password to log on

Enter the authorization statement "grant all privileges on *. * TO 'root' @ '% 'identified BY' login password' with grant option;"

Then refresh "flush privileges;"

Return to HeidiSQL in win7 and continue the test.

5. We speculate that the cause may be the built-in firewall of centos7.

Set Applications-Sundry-Firewall after logging on to the GUI using the command line "startx"


On the configuration page, Select Ports from the default zone-public tab, click Add, enter mariadb port 3306, and then confirm. Effect.


6. Return to HeidiSQL in win7 and test the connection!

7. After centos is restarted, HeideSQL cannot connect to the server.

Go to Applications-Sundry-Firewall-Ports to check the settings and find that the open rules for port 5th in step 1 have disappeared.

The previously set rule is only a temporary rule. After firewall is reloaded, the rule becomes invalid.

To set Permanent rules, the Configuration must be set to Permanent first. For example:


Open the Ports page again, click Add, enter the port number 3306, and then confirm.

No matter how many times centos is restarted, you can log on remotely.

/* It will take nearly eight hours for dev c ++ to complete this step. */

8. First, you need to download the devpak of mysql. devpaks.org is blocked somehow and dev c ++ cannot be updated. So I had to use goagent to access it through a browser and finally found it.

9. After the download, Install the MySQL-6.1.5-1aved.DevPak through the dev c ++ tool-Package Manager-Install"


10. After the installation is successful, go to dev c ++'s "tools-compilation options"

A. Add the "-lmysql" command to the connector on the compiler page"


B. Directory page-c include File page/c ++ include file page add mysql package path "dev-cpp installation directory \ include \ MySQL"


11. Import "libmysql. dll" from "dev-cpp installation directory \ lib" to "C: \ Windows \ SysWOW64". Otherwise, the system reports an error during compilation.


If an error is returned, copy it to "C: \ Windows \ system32"

12. compile routine


#include <mysql.h>
#include <stdlib.h>
#include <stdio.h>

int main (int nArguments, char * pszArguments [])
{
MYSQL * conn;
MYSQL_RES * res;
MYSQL_ROW row;
char * server = "192.168.124.128"; // The centos server ip confirmed in the first step
char * user = "root";
char * password = "123456"; / * Change to your password here * /
char * database = "mysql";
conn = mysql_init (NULL);
/ * Connect to database * /
if (! mysql_real_connect (conn, server,
user, password, database, 0, NULL, 0)) {
fprintf (stderr, "% s \ n", mysql_error (conn));
}
/ * send SQL query * /
if (mysql_query (conn, "show tables")) {
fprintf (stderr, "% s \ n", mysql_error (conn));
}
res = mysql_use_result (conn);
/ * output table name * /
printf ("MySQL Tables in% s database: \ n", database);
while ((row = mysql_fetch_row (res))! = NULL) printf ("% s \ n", row [0]);
/ * close connection * /
mysql_free_result (res);
mysql_close (conn);
// system ("PAUSE");
return 0;
} 

Running result




Task 2, mission accomplished!





Related Article

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.