shajiindia has asked for the wisdom of the Perl Monks concerning the following question:
I am running a database utility and I am creating a database through a menu driven script. I am getting the following error
DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-secure-test' at line 1 at C:/Users/Sennovate/workspace/Perl/Automation/Sennovate/MySQL DB Creation/ssg-db-utility.pl line 79, <STDIN> line 5.
I am using Strawberry Perl 5.20.1
Here is my code snippet
sub create_database { print "Please enter the hostname:"; chomp($hostname = <STDIN>); print "Please enter the name of the new MySQL database:"; chomp($database = <STDIN>); $dsn = "dbi:$driver::$hostname:$port"; print "Please type the MySQL root username:"; chomp($username = <STDIN>); print "Please type the MySQL root password:"; chomp($password = <STDIN>); $dbh = DBI->connect($dsn, $username, $password); $result = $dbh->do("create database $database"); $dbh->do("use $database"); if($result) { say "Database '$database' created successfully"; } else { say "Database '$database' creation failed"; exit; } }
Here is the input
---------------------------------------- S E N N O V A T E I N C SSG Database Utility - Version 1.1 Copyright Sennovate Inc, 2014 ---------------------------------------- M E N U ------- 1. Create new database 2. Connect to existing database 3. Create tables 4. Create user 5. Drop existing database 6. Quit Please enter your choice:1 Please enter the hostname:db0002.stage-us.sennovate.com Please enter the name of the new MySQL database:ssg-secure-test Please type the MySQL root username:ssg-stage Please type the MySQL root password:p7ZUrf59zJHYMMuLKfWTxC DBD::mysql::db do failed: You have an error in your SQL syntax; check +the manual that corresponds to your MySQL server version for the righ +t syntax to use near '-secure-test' at line 1 at C:/Users/Sennovate/w +orkspace/Perl/Automation/Sennovate/MySQL DB Creation/ssg-db-utility.p +l line 79, <STDIN> line 5. Database 'ssg-secure-test' creation failed DBD::mysql::db do failed: You have an error in your SQL syntax; check +the manual that corresponds to your MySQL server version for the righ +t syntax to use near '-secure-test' at line 1 at C:/Users/Sennovate/w +orkspace/Perl/Automation/Sennovate/MySQL DB Creation/ssg-db-utility.p +l line 80, <STDIN> line 5.
Please help
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: DBD::mysql::db do failed: You have an error in your SQL syntax;
by choroba (Cardinal) on Jan 05, 2015 at 11:23 UTC | |
Re: DBD::mysql::db do failed: You have an error in your SQL syntax;
by KurtSchwind (Chaplain) on Jan 05, 2015 at 12:36 UTC | |
by rnewsham (Curate) on Jan 05, 2015 at 12:45 UTC | |
by shajiindia (Acolyte) on Jan 05, 2015 at 13:07 UTC | |
by KurtSchwind (Chaplain) on Jan 05, 2015 at 12:54 UTC | |
Re: DBD::mysql::db do failed: You have an error in your SQL syntax;
by locked_user sundialsvc4 (Abbot) on Jan 05, 2015 at 13:39 UTC |