Here are the pre-requisites of this procedure
Server
- MySQL database with remote connections allowed
- MySQL ODBC driver
- Microsoft Access
Step 1: Setting up the Server
This step is not needed if you run MySQL on the same machine as your client. Let's assume that you run it on machine within your network. Hence the following topology:
In this case what you have to do first is to make sure that your mysql daemon is listening to its network address rather then localhost.Check your MySQL configuration file which is on OpenSUSE (and a lot of other distros) is located in /etc/my.cnf
Find the following line:
bind-address:
If you have there your server network address (192.168.0.100 in this example), then leave it as it is. If the address is 127.0.0.1 - then change it to your network address. If you have made changes, restart the server.
# /etc/init.d/mysql restart
Second thing to do is to give permission to a database from a remote host. In our case it would be 192.168.0.101 machine. Log in to mysql using the command line client as root:
$ mysql -uroot -p
enter your password, and you should get a mysql terminal. In this example I want to be able to manage a database called movietime, and the username is admin. So, to sum up all I want to achieve here is to allow full access of user admin to database movietime from a host 192.168.0.100. This can be done with the Grant command the following way:
> GRANT ALL ON movietime.* TO 'admin'@'192.168.0.100';
then run Flush Privileges for server to reload GRANT tables
> FLUSH PRIVILEGES
quit the shell
> exit
You can read more on Database Grant Syntax and Security here
By this stage, you should have a MySQL service listening to its port (3306) on its network address (192.168.0.100) and accept connections from 192.168.0.100 for a user admin, giving him all privileges on database movietime.
Step 2: Testing the remote connection
If you have text based client installed on your workstation, try to connect with it to a database server
mysql.exe -u admin -h 192.168.0.100 -d movietime -p
Omit option -p if you allow admin to connect without a password. After a password prompt you should get a text based interface to your database, pretty much the same as back on your server side.

You can get ODBC driver for MySQL from here. Download and install it, nothing much else to do with it. Once its installed go to Start -> Control Panel (or Settings -> Control panel if in classic view) -> Administrative Tools -> Data Sources -> System DSN
Then Click on Add, select MySQL ODBC 5.1 Driver (bottom of the list) fill out the form like on the picture (adjust your settings, obviously).
Step 4: Linking Access Database to ODBC
Last step is to link the database in access. Open Microsoft Access and create a new database. This database (mdb) is going to be a front-end wrapper for the MySQL ODBC source. Then click on File -> Get External Data-> Import -> ODBC Databases -> Machine Data Import -> select MovieTime database.
Then do File -> Get External Data -> Link Tables -> ODBC Databases -> Machine Data Import -> select MovieTime database
This step might not be needed, though you'll have to do it everytime you change database schema. You should see all your database tables in Access now. Try adding a record by clicking one of tables and adding one more row:
So this is how you can use Microsoft Access as a front end for MySQL database.


0 comments:
Post a Comment