How Can I connect matlab with my sql in other pc
3 次查看(过去 30 天)
显示 更早的评论
i can connect matlab to mysql, but only in localhost. and i will try to connect the matlab to other IP, not only to local IP(127.0.0.1 or localhost).
0 个评论
回答(1 个)
Piyush Kumar
2024-10-30
Hi,
To connect MATLAB to a MySQL database on another PC, you’ll need to ensure a few things are set up correctly.
1. Find the ip-address of machine from where you want to connect.
2. In the MySQL server configuration, add the following and restart the mysql server to apply these changes.
% my.cnf file
[mysqld]
bind-address = <ip-address-of-client-machine>
3. Granting Access: Granting access to a user from a remote host.
GRANT ALL PRIVILEGES ON *.* TO 'username'@'client_machine_ip' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
4. Firewall Settings: Ensure that the firewall on the remote PC allows incoming connections on the MySQL port (default is 3306).
5. MATLAB Connection: Use the database function in MATLAB to connect to the remote MySQL server. Replace 'remote_ip' with the IP address of the remote PC:
conn = database('your_database_name', 'username', 'password', 'Vendor', 'MySQL', 'Server', 'remote_ip', 'PortNumber', 3306);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!