On the premise that the mysql database has been installed, create a database named WX
Install the Mysql-connect-ODBC driver and select the typical installation type;
After the installation is complete, open the Control Panel and select System and Security—>Administrative Tools
Select a 64-bit ODBC data source (as many bits as you choose)
Select Add SDN
Select MySQL ODBC version number Unicode Driver
Set the data source name (you can write it as you like)
TCP/IP server server name is 127.0.0.1 or localhost
userusername: root
Password: Enter the database password you set yourself
Database: database name (write wx here according to the above)
Clicking test shows that the connection is successful
Then run the following code on matlab:
clc;%Clear screen
clear;%Clear data memory
conn= database('MySql','root','')%Open the database in the MySql data source to read data
sql='select * from login';%sql statement
login =exec(conn,sql);%Execute the SQL statement
Info = fetch(login);%Get information from the login table
Data = Info.Data;%Extract data
Running results: If the command window and Data data are displayed as follows, the connection is successful.