DOSQL.PL - Front end to Invoke the MySQL Shells
dosql.pl dosql.pl mydb # Override default realm database with 'mydb' dosql.pl -cmd 'select count(*) from cars' mydb dosql.pl -cmd "select name from cars where model='chevy'" mydb dosql.pl -read inrealm dosql.pl -read inrealm mydb
dosql.pl -mysqlshow # Show tables in database dosql.pl -mysqlshow payroll # Describe table payroll dosql.pl -mysqlshow -read inrealm [mysqlshow parameters]
This program provides a convenient way to invoke the MySQL shells (e.g. /usr/bin/mysql or /usr/bin/mysqlshow).
It makes use of 'realm' files to get the database connection information. This provides a nice way to avoid the prompt for a password.
Realize, however, that the MySQL shell command line contains your password in clear text and it is possible your password can be seen. Recent versions of the MySQL shell attempt to mask your password to avoid this issue. Depending on your installation, this may or may not be reasonably secure.
This program takes advantage of realm files from DBIx::Connector to find the database connection information. You do not, however, need to have this Perl module installed. Rather, just create the directory $HOME/.db_connactions and create the realm files with your favorite text editor. The format of these is quite simple as you can see from this example:
~> cd .db_connections/ ~/.db_connections> cat test DBD=mysql SERVER=host=ourdhhost.my.company.com USER=readonly PASS=readable DATABASE=payroll
If no fatal errors are detected, the program exits with a return code of 0. Any error will set a non-zero return code.
Written by Terry Gliedt <email@example.com> in 2006-2008 and is copyrighted (C) by Terry Gliedt.