meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| applications:connect_matlab_mac [2022/05/26 21:16] – gregbalco | applications:connect_matlab_mac [2022/05/26 22:24] (current) – gregbalco | ||
|---|---|---|---|
| Line 30: | Line 30: | ||
| What this does is connect port 3306 (the default MySQL port) on the remote MySQL server, through the SSH tunnel host, to localhost port 12345 on the local machine. Thus, it will appear to a database client (such as MATLAB in this case) that the database is located at localhost: | What this does is connect port 3306 (the default MySQL port) on the remote MySQL server, through the SSH tunnel host, to localhost port 12345 on the local machine. Thus, it will appear to a database client (such as MATLAB in this case) that the database is located at localhost: | ||
| + | |||
| + | The port number 12345 is (obviously) arbitrary. You can use anything that is not already in use on your machine. If a port is in use, your computer will behave oddly. Mostly, high-numbered (5 digits) ports are OK. | ||
| Note that this won't work as I have written it here because the SSH host and database IP address don't exist. You'll need to put in the correct values. If you have already been using a different MySQL client, you know what these are. If not, ask Greg or Joe. | Note that this won't work as I have written it here because the SSH host and database IP address don't exist. You'll need to put in the correct values. If you have already been using a different MySQL client, you know what these are. If not, ask Greg or Joe. | ||
| - | One additional item of importance is that when you are done with this, you will have to shut down the SSH process that is keeping the tunnel open. Even if you do nothing, it will eventually die next time your computer goes to sleep, but it is bad practice to leave zombie processes all over the place. | + | One additional item of importance is that when you are done with this, you will have to shut down the SSH process that is keeping the tunnel open. If you don't, it will eventually die next time your computer goes to sleep, but it is bad practice to leave zombie processes all over the place. |
| '' | '' | ||
| Line 39: | Line 41: | ||
| This will generate a bunch of information that will look something like this: | This will generate a bunch of information that will look something like this: | ||
| - | '' | + | < |
| - | balcs | + | balcs |
| + | balcs | ||
| + | </ | ||
| The second line tells you that the SSH process is process 7652 (everything that is running on a *nix system has its own process number). You can shut it down by typing: | The second line tells you that the SSH process is process 7652 (everything that is running on a *nix system has its own process number). You can shut it down by typing: | ||
| Line 50: | Line 54: | ||
| == Connecting MATLAB to the database through the SSH tunnel == | == Connecting MATLAB to the database through the SSH tunnel == | ||
| - | Now that you have an ssh tunnel open to the database, you need to point MATLAB to it. On current MATLAB, it appears the easiest way to do this is to use the 'JDBC data source configuration' | + | Now that you have an ssh tunnel open to the database, you need to point MATLAB to it. On current MATLAB, it appears the easiest way to do this is to use the 'JDBC data source configuration' |
| {{: | {{: | ||
| Line 62: | Line 66: | ||
| '' | '' | ||
| - | This should return a bunch of information about the database connection. You now have a live connection to the database that can be accessed | + | This should return a bunch of information about the database connection. You now have a live connection to the database that can be accessed |
| - | '' | + | '' |
| This should return: | This should return: | ||
| - | '' | + | < |
| + | query_result | ||
| 1×3 table | 1×3 table | ||
| Line 77: | Line 82: | ||
| {' | {' | ||
| - | '' | + | </ |
| What you have just done is send an SQL command to the database and obtain a result as a MATLAB variable that you can now work with in MATLAB. | What you have just done is send an SQL command to the database and obtain a result as a MATLAB variable that you can now work with in MATLAB. | ||
| Line 85: | Line 90: | ||
| '' | '' | ||
| - | To learn more about this, look at the MATLAB documentation for the commands ' | + | If everything is working as intended, the ' |
| + | |||
| + | To learn more about this, look at the MATLAB documentation for the commands ' | ||