Help with DBI, perl, mysql on ubuntu

syed khalid <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <CAHc+NX2Nqf2Pua6KKOdV-6wVfJ_K6SgXGQZ2RnmDMJ0JSUUOSg@mail.gmail.com>
I apologize if this is not the right forum to ask question.

Background
=========

I am running Ubuntu 12.04 on my laptop. it is the desktop version.

I am aslo running MYSQL server version 5.5.29

I am running into some problems which seem fairly basic and could be
related to one or both of the following:

1. It looks like if I specify the "h" flag things work. However, if I use
"root@localhost", I run into problems.

syedk@syedk-ThinkPad-T410:~$ mysql -uroot -hlocalhost -p mysql
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2499
Server version: 5.5.29-0ubuntu0.12.04.2 (Ubuntu)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.

********does not work for root@localhost  (for some reason appends
localhost)

mysql -uroot@localhost -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root@localhost'@'localhost'
(using password: YES)

2.The code that is failing on the install is this.....

#*----------------------------
-----------------------------
 #*- Create a database after checking if it exists
 #*---------------------------------------------------------
 sub create_db
 {
  my ($dbname, $userid, $pass) = @_;

  #*-- check for a duplicate db
 ----->> my $dbh =
DBI->connect("DBI:mysql:mysql:localhost:3306","$userid","$pass");
  my @dbs = $dbh->func('_ListDBs');
  foreach my $db (@dbs)
   { if ($db eq $dbname) { $dbh->disconnect(); return(); } }

  #*-- create the db
  $dbh->do("create database $dbname"); $dbh->disconnect();
  return();
 }

The error I am getting is this Line 138 refers to the ---------> line above)


DBI connect('mysql:localhost:3306'
,'root',...) failed: Access
denied
for user 'root'@'localhost' (using password: NO) at
../TextMine/DbCall.pm line 138
Can't call method "func" on an undefined value at
../TextMine/DbCall.pm line 139.

My mysql may not have all the options loaded?? I loaded DBI but may need
DBD. Also my databases only have this

mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
+--------------------+
2 rows in set (0.00 sec)


-- 
*Syed Khalid*
**
*CEO*
**
*Pacific Cloud*
**
*1-408-655-1096*
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.