my $user = 'somename'; my $password="0123"; my $db ="test"; my $host="localhost"; print "Connecting to terminology database $db as $user... "; my $dsn = "DBI:mysql:$db:$host:$port"; my %attr = (PrintError=>0, RaiseError=>1); my $dbh = DBI->connect($dsn,$Superuser,$pass, \%attr); print "done!\n"; my $sql; print "Creating user $user\n"; $sql = 'CREATE USER ?@? IDENTIFIED BY ?'; $dbh->do($sql, undef, $user, "localhost", $password); print "done!\n"; print "Granting user $user some rights\n"; $sql = 'GRANT ALL ON $db.* TO ?@? IDENTIFIED BY ?'; $dbh->do(q{GRANT ALL ON ?.* TO ?@? IDENTIFIED BY ?}, {}, $db, $user, $host, $password); print "done!\n"; #### Connecting to terminology database test as root... done! Creating user somename done! Granting user somename some rights 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 ''test'.* TO 'somename'@'localhost' IDENTIFIED BY '0123'' at line 1