Use the following outline to connect and query the MySQL server from a Perl script.
1. Declarations
You must require the MySQL package for your script to function properly. Do this by including the following line in your code: use Mysql;
2. Connect To The Database
Some where near the beginning of your script, you need to make your initial connection to the database server. Using the following form, substitute your database, username, and password for the examples to connect successfully. The database must be a valid one that you have created .
Mysql->connect('localhost','DATABASENAME','USERNAME','USERPASSWORD');
3. Executing A Query
You are now ready to begin querying the database server. Most problems that you may incur will generally occur due to syntax errors.
For more information on accessing your MySQL databases through Perl, please visit http://perl.about.com/od/perltutorials/a/perlmysql_3.htm .
- 0 Users Found This Useful