Access and mysql

xiaoxiao2021-03-06  55

Memo 2 articles of Access & Mysql:

USING Microsoft Access with MySQL

Summary

This article demonstrates how to connect to a MySQL server and edit database records using Microsoft Access. It assumes that you have familiarity with MS Access and that you have already installed MySQL on the UW servers.

NOTE: The Procedures Outlined in This Article WERE WRITTEN USING Microsoft Access XP on Windows XP. The Yy Have to Be Adjusted Slightly If You Are Using ANother Version of Microsoft Access Or Windows.

Included On this Page:

Installing The Myodbc Driver Connecting to a MySQL Database from MS Access; Linking and Editing Tables References

Installing the myodbc driver

The ODBC API (Open Database Connectivity Application Programming Interface) provides a way for client programs such as MS Access to access databases on remote servers. Before you can use Access with your MySQL server, you must thus first install the MyODBC driver. To do so FOLLOW THESE INSTRUCTIONS:

Download MyODBC 2.50 to your desktop computer, making sure to select the appropriate installation file for your version of Windows. After downloading, unzip the file, and then double click on Setup.exe. When the MyODBC Ver 2.5 Installation window appears, click Continue. Select MySQL from the list of available ODBC drivers, and then click OK. Files will begin copying to your computer. Select sample-MySQL (MySQL) from the list of available ODBC drivers, and then click Add. When the Add Data Source window pops Up, scroll to the bottom of the list of installed odbc drivers and select mysql. Click Ok. The Tdx MySQL Driver Default Configuration Window Should Appear.

In The Windows DSN Name Field, Type Sample-mysql.in The MySQL Host (Name OR IP) Field, Type Either Ovid.u.washington.edu (staff / faculty / cours / depts site) or vergil.u.washington.edu (student sites), depending on where you installed MySQL.Leave the MySQL database name field blank.In the User field, type root.In the password field, type the root password you chose when you installed MySQL.In the Port field, type the port number you chose when you created your .my.cnf file.Leave the SQL command on connect field blank.Press OK.Click close, and then OK.Close the MyODBC zip file.Congratulations! you have successfully configured MyODBC to connect to Your mysql server, and you can now link to your mysql tables with Microsoft Access.

Connecting to a mysql Database from MS Access; Linking and Editing Tables

. Microsoft Access provides two ways to edit the data in your MySQL databases: importing and exporting data, and linking directly to tables When you import data, you make a copy of a table or query on your local computer; similarly, when you export, you copy information from your local computer back onto your MySQL server. The limitation of this is that you can not directly edit or overwrite tables in your existing MySQL database. Linking, on the other hand, allows you to make a direct connection to a database on Your Mysql Server and Edit Table Entries with MS Access. this section shows you how to do care.

ONCE You Have The Myodbc Driver Installed, You CAN Connect To Your Mysql Server and Edit Database Records Via A MS Access Link. To Connect To Your My My My My My My Mysql Server from MS Access, FOLLOW THESE INSTRUCTIONS:

Create a new Access database, or open a pre-existing Access database you want to link to your MySQL server Click File -.> Get External Data -> Link Tables This will display the Link dialog box Find the Files of Type drop-.. down list at the lower left of the window and click the down arrow Scroll to the bottom of the list and select ODBC Databases () The Select Data Source dialog box will appear;.. it lists the defined data sources for any ODBC drivers installed on your computer. Click on the Machine Data Source tab at the top, select sample-MySQL, and click OK. you should now see the TCX mysql Driver connect box with the default values ​​you entered when you installed the MyODBC driver. In the MySQL database name field, enter the name of the database you want to import, and click OK. you should now be presented with a list of all the tables in your database. Select the tables you would like to view or modify and click OK. Access may ask you to select unique Identifiers for some Tables; T his is only necessary if you will be updating records The tables you selected should now appear with globe icons in the tables section of your Access database;.. double-click a table to view or modify its contents As long as the table has at least one unique identifier, any changes you make will be updated on the MySQL server as you work.Note: while you can view table and column properties of linked tables in MS Acess, you can not configure fields, tables, or database schema phpMyAdmin, however. Handles Such Changes Very Ably.

References

For more information about myodbc and using Microsoft Access with mysql, see myodbc faq: MS acess related.

MigRating from Microsoft Access To MySQL

Paul duboispaul@kitebird.com

Document Revision: 1.01last Update: 2003-01-25Table of Contents

Introduction Microsoft Access Or MySQL? Reasons to Migrate from Microsoft Access To MySQL Migration Strategies Methods of Transferring Databases from Microsoft Access To MySQL

Telling Microsoft Access To Export ITS OWN TABLES Converters That Generate Intermediate Files Converters That Perform Direct Data Transfer Conclusion Resources AcknowledgeLendgment

Introduction

. Businesses that use Access eventually begin to struggle against its limitations Now they have an alternative: Move data repositories to a system that provides better performance and reliability and that is more flexible in how it allows information to be used MySQL provides the features you need. to follow this course. MySQL includes a business strength database server that runs under either Windows, Linux, or Unix. MySQL features InnoDB, the table type that provides performance and reliability enhancements such as row-level locking, transaction support, and automatic crash recovery . by using MySQL as a data management platform, you can continue to manipulate your data through Access as a front end if you wish. But you can also exploit your data in other ways, for example, by using MySQL to help you establish or strengthen Your Web Presence. To do this, Deploy a Web Server That Handles Requests from People Who Visit Your Site and Tie It To MySQL Using A Web Programming Language. a Pop Ular Combination Employs The Apache Web Server and The Perl and PHP Programming Languages. Perl and PHP Both Are Extreme Popular for Web Programming, and Both Interface Easily with MySQL.

The following article explores reasons to consider using MySQL instead of Access for data management, and provides guidelines for transferring information out of Access and into MySQL when you're ready to make the switch.Microsoft Access or MySQL?

Microsoft Access is a popular data management application that allows you to store information in tables that it manages directly from the local disk. You can also use Access as a front end, that is, as an interface to information that is located elsewhere and handled by . another storage management system In this case, Access acts as a client that connects to a server that provides the data The MySQL database system is one such storage manager;. if you install the MySQL Connector / ODBC driver (formerly known as MyODBC), ................... ..

Access has its strengths, such as an easy to use interface Access also has its limitations -. It's generally used as a personal or single-user application, typically for managing limited amounts of data (Access is not commonly used for databases hundreds of. megabytes in size, for example.) Because of its storage management limitations, you may be considering how to retain the Access interface but migrate your information to a storage manager with greater capabilities. Or you may even be considering a move away from Access entirely. This article outlines some benefits that you stand to gain by using MySQL to manage your data, and provides some guidelines to help you migrate locally stored Access tables to MySQL. The final section of the article lists links to locations where you can find the tools discussed Here.reasons to migrate from Microsoft Access To MySQL

Use of MySQL as a storage manager for Access offers several benefits. One is that you can use your information in additional ways when it's not locked into Access. Other differences pertain more specifically to the case where you intend to continue using Access as the user interface TO YOUR INFORMATION.

Deployment of information. When your information resides in MySQL, you're free to continue using it from Access if you wish, but a number of other possibilities open up as well. Any kind of MySQL client can use the information, not just Access. This allows your data to be exploited more fully in more contexts, and by more people. For example, other people can use the data through the standard MySQL client programs or from GUI-based applications. your database also becomes more accessible over the Web. Access now provides some capabilities for making a database available on the Web, but if MySQL manages the database, you have a wider range of options. MySQL integrates easily with Web servers like Apache through any of a number of languages, such as Perl, PHP , Python, Java, and Ruby. This allows you to provide a Web interface to your database with the language of your choice. In addition, the interface can be accessed by browsers on many types of machines, providing a platform-independen t entryway to your information All of these components can be obtained for free -... MySQL, Apache, and the languages ​​just mentioned have been released as Open Source You can also obtain them in packages that include support.Multiple-user access Although Access provides some data sharing capabilities, that is not really its strength. It has the feel of a single-user data manager designed for local use. MySQL, on the other hand, easily handles many simultaneous users. It was designed from the ground up To run in a networked environment and to be a multiple-user system this is capable of servicing large number.

Management of large databases. MySQL can manage hundreds of megabytes of data, and more. Care to try that with Access? Security. When Access tables are stored locally, anyone can walk up to your Windows machine, launch Access, and gain access to your tables. It's possible to assign a database a password, but many people routinely neglect to do so. When your tables are stored in MySQL, the MySQL server manages security. Anyone attempting to access your data must know the proper user name and password for connecting TO mysql.

Backup management. If you work in an organization that supports many Access users, migrating data to MySQL provides a benefit for backups and data integrity. With Access databases centralized in MySQL, they're all backed up using the regular MySQL backup procedures that already exist . at your site If individual Access users each store their data locally, backup can be more complicated:. 50 users means 50 database backups While some sites address this problem through the use of network backups, others deal with it by making backups the responsibility of Individual Machine Owners - Which Unfortunately Sometimes Means No Backups At ALL.

Local disk storage requirements. Local Access database files become smaller, because the contents of tables are not stored internally, they're stored as links to the MySQL server where the tables reside. This results in reduced local disk usage. And, should you wish To Distribute A Database, Less Information Need Be Copied.

Cost. MySQL can be obtained for free. Access can not. Providing other means of using your database (such as through a Web interface) can reduce your dependence on proprietary software and lower your software acquisition and licensing costs.Hardware choices. MySQL runs on several Platforms; Access Is A Single-Platform Application. If You Want To Use Access, Your Choice of Hardware Is Determined for you.

MIGRATION Strategies

Should you wish to migrate from Access to MySQL, you can do so either partially or completely It's not without reason that Access is popular -. It provides an interface that many people are comfortable working with If you're such a user, you. can continue to use the interface by migrating partially: Transfer locally stored Access tables to MySQL, then set up links in the Access database that point to the tables managed by MySQL server This way you continue to enjoy the familiarity of the Access interface (the. Tool with Which You're Conversant, But Also Take Advantage of The Strengths of MySQL for Data Storage, Management, And Security.

If You're Less Tied To The User Interface, You CAN Migrate Completely Away from Access. Transfer your access tables to mysql, The use your information with Tools Intended for Working with MySQL.

Methods of Transferring Databases from Microsoft Access To MySQL

In general, to migrate information from Access to MySQL, you first copy the contents of your tables from an Access database to the MySQL server. (To perform the operation of transferring the tables to MySQL, you can choose from several methods, described below. ) If you plan to continue using Access for the interface to your data, the next step after transferring the tables is to replace them with links: Delete the tables stored in your Access database, establish an ODBC connection from Access to the MySQL server, and recreate the tables as links to the MySQL tables. (Naturally, before you delete anything, it's prudent to make a backup first, just in case something goes wrong.) If you do not plan to continue using Access, you need not create any Links.some Transfer Methods Require Making An ODBC Connection To The MySQL Server. for this You CAN Use MySQL Connector / ODBC, The MySQL-Specific ODBC DRIVER.

Telling Microsoft Access To Export ITS OWN Tables

One approach to migrating data from Access to MySQL is to use the export feature provided by Access itself to write out the contents of each table as a text file. Each file then can be loaded into MySQL using a LOAD DATA statement or the mysqlimport command- line utility. Suppose you export a table mytable into a file mytable.txt using CSV (comma separated values) format, and you want to import it into a table named mytable in a MySQL database named mydb. you can invoke the mysql program, then Issue a loading data statement to import the file like this:

C: /> mysql mydb

MySQL> Load Data Local Infile 'MyTable.txt'

-> INTO TABLE MYTABLE

-> Fields Terminated by ',' Enclosed by '"'

-> Lines terminated by '/ r / n';

Alternative, use mysqlimport from the command line (Type The Command All On One line): c: /> mysqlimport --Local --fields-terminated-by =,

--fields-enclosed-by = '""

--Lines-Terminated-by = '/ r / n'

Mydb myTable.txt

If you need to provide connection parameters such as the hostname, user name, or password, list the mysql or mysqlimport command line before the database name:

C: /> mysqlimport --Local --fields-Terminated-by =,

--fields-enclosed-by = '""

--Lines-Terminated-by = '/ r / n'

-h Some_Host -P -U Some_user

Mydb myTable.txt

The advantage of this approach is that it requires no special conversion tools. It can be used to produce data files even on machines that have no MySQL support. (If you do not have the MySQL client programs installed on your Access machine, create the data files, then copy them to another machine where the MySQL programs are installed and load the files into MySQL from there.) The disadvantage is that the MySQL tables must already exist before you can load data into them, so you must issue the appropriate CREATE .

Converters That Generate Intermediate Files

A second approach to data transfer is to use a converter that reads an Access table and produces from it one or more files containing SQL statements that create the table for you and load data into it. Then you execute the intermediate SQL file or files using the Mysql Program. Several Free Converters That Work Like this Are Available, Each of Which Takes The Form of An Access Module:

exportsql.txtWorks with Access95, Access97, Access2000. Exports all tables in a database, producing one file containing DROP TABLE statements (in case you want to remove MySQL tables created during an earlier data transfer exercise) and another file containing CREATE TABLE and INSERT statements . for creating and loading the tables The files are written to the C: / TEMP directory.access_to_mysql.txtExports all tables in a database into a file C: /TEMP/mysqldump.txt containing dROP TABLE, CREATE TABLE, and INSERT statements to drop any existing MySQL tables and recreate them. Less sophisticated than exportsql.txt in terms of type conversion and handling of special characters.mdb2sql.basAccess97 only. Exports selected tables to files in a directory of your choosing. Writes a data file for each selected table , Plus One SQL Script Containing Create Table Statements for Creating The Tables and Load Data Statements for Importing The Data Files Into Them.near The Beginning Of The Source Code for each of these converters, you'll find instructions that you should read, because the details of the process for generating the SQL and data files are converter-specific. Also, be sure to note any prerequisites that must be satisfied before using the converters. THESE INCLUDE The FOLLOWING:

Both exportsql.txt and access_to_mysql.txt expect to write files to the c: / temp Directory, So you must create this directory if it doesn't exist: c: /> mkdir C: / Temp

Alternatively, you can modify the module source so that it writes files to another existing directory.If you want to use exportsql.txt to convert Access2000 tables, you need to enable support for the DAO (Data Access Objects) interface. From Access, go into the Visual Basic editor, select the Tools >> References menu option, then enable the "Microsoft DAO 3.6 Object Library" option in the window that comes up.mdb2sql.bas requires that you have Advanced Wizards installed, because it uses the Documenter function included in that Wizard set.After following the export procedure for a converter that generates intermediate SQL files from Access tables, you'll end up with one or more files that need to be executed with the mysql program, as follows. Assuming that you want To create Tables in a database name named mydb, you can execute a SQL File File.sql like this:

C: /> mysql mydb

If you need to provide connection parameters, List The THE Command Line Before The Database Name:

C: /> mysql -h some_host -p -u some_user mydb

Converters That Perform Direct Data Transfer

Some conversion tools can transfer data directly from an Access database into MySQL. That is, they create the MySQL tables for you and load the information into them as well. This avoids the need for any intermediate files. On the other hand, such tools require That You Be Aable To Connect To The MySQL Server from The Machine On Which Your Access Information Is Stored. (this Requirement Is Easily Satisfied if you install mysql on your access machine.)

Tools That CAN Perform Direct Data Transfer Are:

MyAccess $ 30 shareware. (Non-registered copies are fully functional, but an annoyance dialog that must be dismissed pops up every five minutes.) Works with Access97, Access2000. MyAccess is an Access add-in that allows direct transfer when you connect from Access to MySQL over an ODBC connection.DBToolsFree. Works with Access97, Access2000. DBTools actually is intended primarily as an application for administering MySQL, but it includes data import capabilities that can be used to read Access databases for transfer to MySQL. (It can also read data from other sources such as Excel spreadsheets, making it particularly useful for transferring to MySQL information that is stored in a variety of formats.) Because DBTools reads Access databases directly, you can use it to migrate Access tables even if you do not Have Access Installed Locally, As Long As you have the database files containing the tables to be transferged. dbtools does not required odbc.mysqlfrontfree. mysqlfront is Similar in Ma ny ways to DBTools. It can read Access97 and Access2000 files directly. If ODBC is installed, MySQLFront can import information into MySQL from ODBC data sources over the network. (Unfortunately, MySQLFront development has ceased and it is no longer distributed by its author. However, you may be able to find it on alternate download sites by using a search engine.) As an example how one of these tools works, here's how you'd use DBTools to perform data transfer from Access to MySQL. Begin by visiting the DBTools Download Page At http://www.dbtools.com.br/, Transferring The Installer (a program named setup.exe), and running it. This will install dbtools on Your Machine.

If you want to transfer Access2000 databases, you need to enable DAO. (If you do not, DBTools will crash whenever you try to open an Access2000 database.) To turn on DAO, launch DBTools (it will tell you there is no server profile;. that's normal), select the Options >> Preferences menu item, and select the DAO 3.6 option Then quit and relaunch DBTools, because DAO is not actually activated until the next launch after you enable it.With DBTools running, establish a connection to your MySQL server. (Click the Server icon in the toolbar or use the Server >> Add Server menu item to define a profile for the MySQL server you want to connect to.) you must be connected to the server before you can transfer Information; Many of The Menu Items and Icons in The Tool Bar Are Disabled Until You Establish A Connection, Including Those Related To Importing Data.

After connecting to MySQL, use the Import Data Wizard to select the Access database file containing the tables you want to transfer. One of the dialogs presented during this process asks you to select the file type for the kind of database you want to use. Select .

If you intend to continue using Access after transferring the tables, open the database from Access, delete the tables that you just transferred to MySQL, connect to the MySQL server, and set up links to the tables.

Conclusion

This article lays out some of the reasons you may find it advantageous to switch from storing and managing data using Access, and to use MySQL instead. These include multiple-user availability, security, and ability to manage large amounts of information. The article also Describes Some Converting Access Data Into MySQL. if're Ready To Move Beyond The Limitations of Access, MySQL Provides The Features You Need.Resources

Mysql and MySQL Connector / ODBC, The MySQL Driver ODBC, Are Available from The MySQL AB Web Site At http://www.mysql.com/.

Information About Microsoft Access May Be Obtained At: http://www.microsoft.com/office/access/.

Links for the conversion tools discussed in this article are available at the Contributed Software page of the MySQL Web site (http://www.mysql.com/doc/en/Contrib.html). Some of the converters have their own pages as Well. Thase May Provide Versions That Are More Up-to-Date THAN Those Available on The MySQL Web Site:

DBTOOLS: http://www.dbtools.com.br/exportsql.txt: http://www.cynergi.net/exportsql/myaccess: http://www.accessmysql.com/

Acknowledgment

. The corrent version of the original.

转载请注明原文地址:https://www.9cbs.com/read-87502.html

New Post(0)