473,386 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

DBI with mysqld

Hi everybody.

Can I use DBI to interface Perl with mysqld running locally rather than
with a 'true' MySQL server?

If not DBI, how can I do this?

aTdHvAaNnKcSe

--
JAY VOLLMER
JV******@VISI.COM
Aug 7 '05 #1
5 1923
Jay Vollmer (jv******@visi.com) wrote:
: Hi everybody.

: Can I use DBI to interface Perl with mysqld running locally rather than
: with a 'true' MySQL server?

: If not DBI, how can I do this?

All modern computer systems are capable of being "servers" (though some
OS's are crippled on purpose to force you to buy a more expensive "server"
versions).

If you have a mysql database installed and the mysql processes running on
your local computer then your local computer is the mysql server.

In that case you can use DBI (with perl) to access the database. Just use
"localhost" as the server name.

If you mean that you have database _files_ but aren't running the mysql
processes then I don't know of any tool to access the database tables,
though data dump tools may exist (but I doubt they would allow you to do
updates or "normal" queries).

I suspect you are just confused. Normally a mysql installation will
include files containing data and programs that are started when the
computer is booted that are the processes with which you can communicate
to access the data. You can use the mysql client program, or DBI (in
perl) or various other libraries with other languages to talk to the
processes so as to access the data.

--

This space not for rent.
Aug 7 '05 #2
On Sat, 06 Aug 2005 21:28:00 -0800, Malcolm Dew-Jones wrote:
Jay Vollmer (jv******@visi.com) wrote:
: Hi everybody.

: Can I use DBI to interface Perl with mysqld running locally rather than
: with a 'true' MySQL server?

: If not DBI, how can I do this? If you have a mysql database installed and the mysql processes running on
your local computer then your local computer is the mysql server.

In that case you can use DBI (with perl) to access the database. Just use
"localhost" as the server name.


Thanks for the reply. In answer; I tried using localhost, but it doesn't
work.

--
JAY VOLLMER
JV******@VISI.COM
Aug 7 '05 #3
Jay Vollmer (jv******@visi.com) wrote:
: On Sat, 06 Aug 2005 21:28:00 -0800, Malcolm Dew-Jones wrote:

: > Jay Vollmer (jv******@visi.com) wrote:
: > : Hi everybody.
: >
: > : Can I use DBI to interface Perl with mysqld running locally rather than
: > : with a 'true' MySQL server?
: >
: > : If not DBI, how can I do this?

: > If you have a mysql database installed and the mysql processes running on
: > your local computer then your local computer is the mysql server.
: >
: > In that case you can use DBI (with perl) to access the database. Just use
: > "localhost" as the server name.

: Thanks for the reply. In answer; I tried using localhost, but it doesn't
: work.

"it doesn't work." is not a good enough description. Many things could be
wrong. At a minimum you need to tell us the exact error message and error
code, and also show us a minimal script that doesn't work.

--

This space not for rent.
Aug 7 '05 #4
On Sat, 06 Aug 2005 23:19:55 -0800, Malcolm Dew-Jones wrote:
Jay Vollmer (jv******@visi.com) wrote:
: On Sat, 06 Aug 2005 21:28:00 -0800, Malcolm Dew-Jones wrote:

: > Jay Vollmer (jv******@visi.com) wrote:
: > : Hi everybody.
: >
: > : Can I use DBI to interface Perl with mysqld running locally rather than
: > : with a 'true' MySQL server?
: >
: > : If not DBI, how can I do this?

: > If you have a mysql database installed and the mysql processes running on
: > your local computer then your local computer is the mysql server.
: >
: > In that case you can use DBI (with perl) to access the database. Just use
: > "localhost" as the server name. "it doesn't work." is not a good enough description. Many things could be
wrong. At a minimum you need to tell us the exact error message and error
code, and also show us a minimal script that doesn't work.


Here is an example of the code:

#!/usr/bin/perl
use DBI;
$drh = DBI->install_driver( 'mysql' );
$dbh = DBI->connect("DBI:mysql:test:", 'username', 'password');
die "Cannot connect: $D: $DBI::errstr\n" unless $dbh;

$sth = $dbh->prepare("select * from test;");
$sth->execute;
while (($first_name, $field1, $field2, $field3) = $sth->fetchrow)
{
#Do something here;
}

I get the following error:

DBI connect('test:localhost','jvollmer',...) failed: Access denied for
user:
'jvollmer@localhost' (Using password: YES) at ./testsql.pl line 4
Cannot connect: : Access denied for user: 'jvollmer@localhost' (Using
password: YES)

But I have no trouble accessing the database using the mysql client.

Okay, that's the exaple and the error. I fixed it by removing the
servername, login and password entirely. It works if I do this:

$dbh = DBI->connect("DBI:mysql:test:");

Thanks for your time anyway.

--
JAY VOLLMER
JV******@VISI.COM
Aug 7 '05 #5
Jay Vollmer wrote:
DBI connect('test:localhost','jvollmer',...) failed: Access denied for
user:
'jvollmer@localhost' (Using password: YES) at ./testsql.pl line 4
Cannot connect: : Access denied for user: 'jvollmer@localhost' (Using
password: YES)

But I have no trouble accessing the database using the mysql client.
I assume when it works with the mysql client, you are not specifying the
username and password. You'd probably get the same error above if you
did this:

C:> mysql -u jvollmer -p test
Password:
(and enter your password when prompted)
Okay, that's the exaple and the error. I fixed it by removing the
servername, login and password entirely. It works if I do this:

$dbh = DBI->connect("DBI:mysql:test:");

Thanks for your time anyway.


I'm glad it's working. For what it's worth, we can explain why you got
that error, it might help you in the future.

You had the database on your local system, and the MySQL service
running, but you hadn't granted access to the database for user jvollmer
when he connects using the password you entered.

You can set up a new user account by using the 'mysql' database and
running this statement:

mysql> grant all on test.* to 'jvollmer'@'localhost' identified by
'password';
(substitute the password you want in place of 'password', of course)

See http://dev.mysql.com/doc/mysql/en/adding-users.html for further
reading on this topic.

Regards,
Bill K.
Aug 7 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stephane Raimbault | last post by:
I've been searching the mailing list for a solution to my problem with "mysqld got signal 11;" and I haven't seen any answers that might help me. This is the situation. I have a db that is being...
0
by: Maciej Wiznerowicz | last post by:
Dear Sirs, I can not start MySQL server. More specifically, MySQL was running fine all the time since installation. It stopped working after I used FmPro Migrator to convert some File Maker...
0
by: Robert Morgan | last post by:
------=_NextPart_000_0008_01C3600F.7D6CBCC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Shut down my Linux PC running MySqld and rebooted this...
0
by: Robert Morgan | last post by:
------=_NextPart_000_0009_01C36013.CF9CC9F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ----- Original Message -----=20 From: Robert Morgan=20...
0
by: Gary Cote | last post by:
>Description: I've recently compiled mysql 4.0.14 on redhat 8.0. The installation fails, however, when running mysql_install_db. I've attached a transcript below. I gather from searching the...
3
by: Paul | last post by:
I'm using ssh to administer a mysql server, version 3.23.49, which I just installed. The problem when starting mysqld: I type "mysqld" at the shell prompt and hit return, then I get the message...
4
by: Alex Shi | last post by:
Hi, In /etc/my.cnf I put an entry under section for mysqld.log as following: log = /var/log/mysqld.log However, mysqld actually does not log anything. Can any one out here help me to make...
1
by: Jeremy Kohansimeh | last post by:
Hello, I just installed version 4.0.21 on a Mandrake 8.2 system. I cannot get the MySql daemon to run. I am using the following commands, and receiving these errors: $mysqld_safe...
0
by: kelvlam | last post by:
I have written a service that is depending on mysqld. The service startup just fine, but I would like to have my service *always* shutdown first before mysqld does. That way I can add some log...
0
by: tomzam | last post by:
I'm trying to get mysql working on Fedora Core 4. Actually trying to start the program mysqld without fatal errors. I posted this message first on the linux misc group - but no luck so far. Maybe...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.