Can"t connect to local host MySQL database
Can"t connect to local host MySQL database
am 28.03.2009 15:18:49 von veneff
Hello,
I'm having trouble connecting to my MySQL database on a Windows XP SP2
system via Perl.
use DBI;
use DBD::mysql;
Can't connect to MySQL server on 'localhost' (10061) at ... this statement:
our $dbh =
DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","root","")
|| die "could not open CNCJobs.MySQL database! $DBI::errstr";
Note that the above line probably wrapped.
Version info:
perl version v5.10.0 built for MSWin32-x86-mulit-thread by ActiveState
MySQL Server version: 5.1.32-community
DBI::VERSION = 1.607
DBD::mysql::VERSION = 4.005
I am able to use the MySQL Command line statement:
mysql -u root -h localhost test.
and can successfully use a select query on the database.
Any ideas?
Vance
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Re: Can"t connect to local host MySQL database
am 29.03.2009 17:04:16 von veneff
Hans,
Thank you for your response!
I tried:
CREATE USER 'CNCJobs'@'%' IDENTIFIED BY '1a2b3c';
GRANT ALL PRIVILEGES ON *.* TO 'CNCJobs'@'%' WITH GRANT OPTION;
adn then:
our $dbh =
DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","CNCJobs","1a2b3c")
|| die "could not open CNCJobs.MySQL database! $DBI::errstr";
I then tried:
CREATE USER 'CNCJobs'@'localhost' IDENTIFIED BY '1a2b3c';
GRANT ALL PRIVILEGES ON *.* TO 'CNCJobs'@'localhost' WITH GRANT OPTION;
and then:
our $dbh =
DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","CNCJobs","1a2b3c")
|| die "could not open CNCJobs.MySQL database! $DBI::errstr";
and finally I tried (your original suggestion):
GRANT SELECT ON test.* TO testuser@localhost IDENTIFIED BY '1a2b3c';
and then:
our $dbh =
DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","testuser","1a2b3c")
|| die "could not open CNCJobs.MySQL database! $DBI::errstr";
and also:
our $dbh =
DBI->connect("DBI:mysql:database=test;host=localhost;port=33 06","CNCJobs","1a2b3c")
|| die "could not open CNCJobs.MySQL database! $DBI::errstr";
The change in the last attempt was just capitalizing DBI in "dbi:mysql...".
I got the same (and the original) error on all three (four) attempts.
Is there a log that would show connection attempts to a MySQL database?
The Apache error log indicated the same error message, so no help there.
Thanks again for your response!
Vance
Hans Ginzel wrote:
> Do you realy use an empty password for the root account?
>
> Log to your db as root from commandline;
> create user:
> GRANT SELECT ON tets.* TO new_user@localhost IDENTIFIED BY
> 'some_pass'
>
> http://dev.mysql.com/doc/refman/5.1/en/adding-users.html
>
> and try connect
>
> DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","new_user","some_pass")
> or die "Could not open CNCJobs.MySQL database: $DBI::errstr";
>
> Hans
>
>
> On Sat, Mar 28, 2009 at 10:18:49AM -0400, Vance E. Neff wrote:
>
>> Hello,
>>
>> I'm having trouble connecting to my MySQL database on a Windows XP SP2
>> system via Perl.
>>
>> use DBI;
>> use DBD::mysql;
>>
>> Can't connect to MySQL server on 'localhost' (10061) at ... this statement:
>> our $dbh =
>> DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","root","")
>> || die "could not open CNCJobs.MySQL database! $DBI::errstr";
>>
>> Note that the above line probably wrapped.
>>
>> Version info:
>> perl version v5.10.0 built for MSWin32-x86-mulit-thread by ActiveState
>> MySQL Server version: 5.1.32-community
>> DBI::VERSION = 1.607
>> DBD::mysql::VERSION = 4.005
>>
>> I am able to use the MySQL Command line statement:
>> mysql -u root -h localhost test.
>> and can successfully use a select query on the database.
>>
>> Any ideas?
>>
>> Vance
>>
>>
>> --
>> MySQL Perl Mailing List
>> For list archives: http://lists.mysql.com/perl
>> To unsubscribe: http://lists.mysql.com/perl?unsub=hans@matfyz.cz
>>
>
>
>
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Re: Can"t connect to local host MySQL database
am 29.03.2009 20:13:35 von Greg Meckes
Make sure that after all that, you type flush privledges.
Greg
Sent from iPhone.
On Mar 29, 2009, at 11:04 AM, "Vance E. Neff" wrote:
Hans,
Thank you for your response!
I tried:
CREATE USER 'CNCJobs'@'%' IDENTIFIED BY '1a2b3c';
GRANT ALL PRIVILEGES ON *.* TO 'CNCJobs'@'%' WITH GRANT OPTION;
adn then:
our $dbh = DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","CNCJobs","1a2b3c") || die "could not open CNCJobs.MySQL database! $DBI::errstr";
I then tried:
CREATE USER 'CNCJobs'@'localhost' IDENTIFIED BY '1a2b3c';
GRANT ALL PRIVILEGES ON *.* TO 'CNCJobs'@'localhost' WITH GRANT OPTION;
and then:
our $dbh = DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","CNCJobs","1a2b3c") || die "could not open CNCJobs.MySQL database! $DBI::errstr";
and finally I tried (your original suggestion):
GRANT SELECT ON test.* TO testuser@localhost IDENTIFIED BY '1a2b3c';
and then:
our $dbh = DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","testuser","1a2b3c") || die "could not open CNCJobs.MySQL database! $DBI::errstr";
and also:
our $dbh = DBI->connect("DBI:mysql:database=test;host=localhost;port=33 06","CNCJobs","1a2b3c") || die "could not open CNCJobs.MySQL database! $DBI::errstr";
The change in the last attempt was just capitalizing DBI in "dbi:mysql...".
I got the same (and the original) error on all three (four) attempts.
Is there a log that would show connection attempts to a MySQL database?
The Apache error log indicated the same error message, so no help there.
Thanks again for your response!
Vance
Hans Ginzel wrote:
Do you realy use an empty password for the root account?
Log to your db as root from commandline;
create user:
GRANT SELECT ON tets.* TO new_user@localhost IDENTIFIED BY
'some_pass'
http://dev.mysql.com/doc/refman/5.1/en/adding-users.html
and try connect
DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","new_user","some_pass")
or die "Could not open CNCJobs.MySQL database: $DBI::errstr";
Hans
On Sat, Mar 28, 2009 at 10:18:49AM -0400, Vance E. Neff wrote:
Hello,
I'm having trouble connecting to my MySQL database on a Windows XP SP2
system via Perl.
use DBI;
use DBD::mysql;
Can't connect to MySQL server on 'localhost' (10061) at ... this statement:
our $dbh =
DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","root","")
|| die "could not open CNCJobs.MySQL database! $DBI::errstr";
Note that the above line probably wrapped.
Version info:
perl version v5.10.0 built for MSWin32-x86-mulit-thread by ActiveState
MySQL Server version: 5.1.32-community
DBI::VERSION = 1.607
DBD::mysql::VERSION = 4.005
I am able to use the MySQL Command line statement:
mysql -u root -h localhost test.
and can successfully use a select query on the database.
Any ideas?
Vance
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=hans@matfyz.cz
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gregmeckes@yahoo.com
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Re: Can"t connect to local host MySQL database
am 30.03.2009 15:57:14 von veneff
Andynic,
Thank you so much!
I had to download the MySQL/odbc connector and discovered that I had to
force use of named pipes for localhost when configuring it even though
it never asked me what that pipe name is.
But, I can now connect to my database via perl.
I wonder if pipes have anything to do with the dbi::mysql connection
problem.
Anyway, thank you again!
Vance
andynic wrote:
> Hi Vance,
>
> I have also had problems connecting.
>
> Am using the sam versions as you (though I'm not sure about the DBD
> version). This is the way I finally successfully installed DBD.
>
> Installing DBD for Perl 5 (command all on one line)
>
> ppm install http://cpan.uwinnipeg.ca/PPMPackages/10xx/
> DBD-mysql
> .ppd
>
>
>
> With that I can connect using DBD from a perl script running from the
> command line. But still not from a CGI script via an Apache Server.
>
> In all cases I have been able to connect using an ODBC connection.
> Here is my connect command:
> ($dbHandle = DBI->connect("DBI:ODBC:$dbSchemaName", $dbUn, $dbPw)
>
> To set up an ODBC connection:
> start --> settings --> control panel -->Administrative tools --> Data
> Sources (ODBC).
>
> Hope this helps.
> Andynic
>
>
> --- On *Sat, 3/28/09, Vance E. Neff //* wrote:
>
>
> From: Vance E. Neff
> Subject: Can't connect to local host MySQL database
> To: perl@lists.mysql.com
> Date: Saturday, March 28, 2009, 3:18 PM
>
> Hello,
>
> I'm having trouble connecting to my MySQL database on a Windows XP
> SP2 system via Perl.
>
> use DBI;
> use DBD::mysql;
>
> Can't connect to MySQL server on 'localhost' (10061) at .... this
> statement:
> our $dbh =
> DBI->connect("dbi:mysql:database=test;host=localhost;port=33 06","root","")
> || die "could not open CNCJobs.MySQL database! $DBI::errstr";
>
> Note that the above line probably wrapped.
>
> Version info:
> perl version v5.10.0 built for MSWin32-x86-mulit-thread by ActiveState
> MySQL Server version: 5.1.32-community
> DBI::VERSION = 1.607
> DBD::mysql::VERSION = 4.005
>
> I am able to use the MySQL Command line statement:
> mysql -u root -h localhost test.
> and can successfully use a select query on the database.
>
> Any ideas?
>
> Vance
>
>
> -- MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe:
> http://lists.mysql.com/perl?unsub=andynic_nl@yahoo.com
>
>
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Trying to get the last inserted ID
am 31.03.2009 17:49:44 von veneff
Hello,
I have inserted a new row into a table that has an auto incrementing key.
For some reason, I don't seem to be able to retrieve it after it is created.
I tried these two statements:
$LoginID = $dbh->last_insert_id( "", "", "Logins", "LoginID" );
and
$LoginID = $dbh->{'mysql_insertid'};
in both cases, $LoginID comes back undefined.
I tried before the COMMIT and after with the same results. Note that
auto commit is currently turned on, so my commits should have anything
to do with anything.
What am I doing wrong?
Note that I have verified that the key is being created with the
expected values.
Vance
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Re: Trying to get the last inserted ID
am 31.03.2009 18:26:45 von Michael Boudreau
--_000_C5F7AE7517EB4mboudreaaduchicagoedu_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
According to "Programming the Perl DBI" (O'Reilly 2000), the syntax varies =
depending on your version of DBD::mysql:
If you used a prepare/execute:
$sth->{mysql_insertid} (1.21_xx)
$sth->{insertid} (1.20_xx)
If you used $dbh->do:
$dbh->{mysql_insertid} (1.21_xx)
$dbh->do("SELECT LAST_INSERT_ID()") (1.20_xx)
On 3/31/09 10:49 AM, "Vance E. Neff" wrote:
Hello,
I have inserted a new row into a table that has an auto incrementing key.
For some reason, I don't seem to be able to retrieve it after it is created=
..
I tried these two statements:
$LoginID =3D $dbh->last_insert_id( "", "", "Logins", "LoginID" );
and
$LoginID =3D $dbh->{'mysql_insertid'};
in both cases, $LoginID comes back undefined.
I tried before the COMMIT and after with the same results. Note that
auto commit is currently turned on, so my commits should have anything
to do with anything.
What am I doing wrong?
Note that I have verified that the key is being created with the
expected values.
Vance
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3Dmboudreau@press.uchi=
cago.edu
--
Michael R. Boudreau
Senior Publishing Technology Analyst
The University of Chicago Press
1427 E. 60th Street
Chicago, IL 60637
(773) 753-3298 fax: (773) 753-3383
--_000_C5F7AE7517EB4mboudreaaduchicagoedu_--