26.1.9.6. Establishing a Remote Connection to System A from System B
If you want to connect to system A from system B with a username
and password of myuser
and
mypassword
, here is a simple procedure.
On system A, follow these steps:
Start the MySQL server.
-
Use GRANT
to set up an account with a
username of myuser
that can connect from
system B using a password of myuser
:
GRANT ALL ON *.* to 'myuser'@'B' IDENTIFIED BY 'mypassword';
The GRANT
statement grants all privileges
to user myuser
for connecting from
system B using the password mypassword
.
To execute this statement, you should be either
root
on system A (or another user who has
appropriate privileges). For more information about MySQL
privileges, refer to
Section 5.8, “MySQL User Account Management”.
On system B, follow these steps:
-
Configure a MyODBC DSN using the following connection
parameters:
DSN = remote_test
SERVER or HOST = A (or IP address of system A)
DATABASE = test (The default database or an appropriate one)
USER = myuser
PASSWORD = mypassword
To set up a DSN-less connection, refer to
Section 26.1.9.5, “Connecting Without a Predefined DSN”.
Check whether you are able to access system A from system B
by using ping or other means. If you are not able to reach
system A, check your network or Internet connections or
contact your system administrator.
Try to connect using DSN=remote_test
. If
it fails, trace the MyODBC log, and take the further steps
based on the error message from the log. If you need further
assistance, send a detailed mail message to
<[email protected]>
.
You can also find a simple HOWTO at
https://www.phphelp.com/tutorial/using-myodbc-to-connect-to-a-remote-database.html.