Database Reference
In-Depth Information
If you are connecting to a remote machine with the server on then specify it using its
domain name, i.e. mysql.domain.com . You can also use the IP number of the machine,
i.e. 1 92 . 168 . 1 . 100
The Database Name field is used to select the MySql database that you are connecting
to. For this example we will use the system mysql database. This is safe if you are just
using your MySQL database to run through the examples in this topic, but if you are on
a live server with other users I would recommend creating a new database to connect
your data source to for security reasons.
The User and Password fields are the user credentials that MyODBC uses to connect to
the MySQL server. You can use any valid username and password, but again for the same
reasons as above it may be better to use a user that has been specifically created for
ODBC MySQL access. It would be a bad idea to use your root account, as this means that
the datasource, if it could connect to the system mysql database, could have full access
to view and change all of your MySQL data.
Unless you have changed it from the default settings, leave the Port field at the default
setting of 3306 .
The SQL command on connect field is used to automatically run a command as soon as
the data source makes a connection to the MySQL server. Leave this blank for our exam-
ple.
If you are using the ODBC source to connect to a server on another machine, the user
must have rights to connect from this machine in the host column of the user table. For
instance, if the machine with the MyODBC connection had the IP number 192.168.1.1, and
the MySQL server had the number 192.168.1.100, the following would apply:
A user created with the following commands would not be able to connect:
GRANT SELECT ON mysql.* TO remoteuser@192.168.1.100;
GRANT SELECT ON mysql.* TO remoteuser@localhost;
A user created with the following commands would be able to connect:
GRANT SELECT ON mysql.* TO remoteuser@*;
GRANT SELECT ON mysql.* TO remoteuser@192.168.1.1;
If you are using a dedicated webserver and dedicated MySQL server for your website on
separate boxes, it is best to clearly define the data source user so that it can only connect
from the specific webservers that require it by specifying the server name or IP address and
not using wildcards for the host entries. This would secure your setup to stop remote users
connecting to your MySQL server from other computers. Remember that if the data source
is being used by a webserver, and a user on another computer, say 192.168.1.200, connects
to that webserver, the data source connection to the MySQL server will come from the web-
server, not the machine 192.168.1.200.
On version 3.3.1 of MyODBC you also have a button that allows you to test your connec-
tion to the data source. It is easier to test the connection now, at this control, rather than try-
Search WWH ::




Custom Search