Prolblème de connection a Mysql
Bonjour
J'ai écrit un code en perl pour me connecté à Mysql mais quand je lance le programme je reçois comme message d'erreur
Code:
DBI connect('database=platform;host=localhost;mysql_socket=/tmp/mysql:3305.sock','myadm05',...) failed: Can't connect to local MySQL server through socket '/tmp/mysql' (2) at mysqlessai.pl line 9
J'ai été voir dans le dossier tmp et je me suis rendu compte que j'avais un fichier qui se nomme "mysql:3305.sock"
Je voulais savoir comment je pourrait utilisé se fichier. je vous donne le code de mon programme
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| #!/com/ASTRIDFS2/webmsd/site_pay/tools/appli_search/ActivePerl-5.10/bin/perl -w
use lib ("/com/ASTRIDFS2/webmsd/site_pay/tools/appli_search/ActivePerl-5.10/lib");
use lib ("/com/ASTRIDFS2/webmsd/site_pay/tools/appli_search/ActivePerl-5.10/site/lib");
use strict;
use DBI();
# Connect to the database.
my $dbh = DBI->connect("DBI:mysql:database=platform;host=localhost",
"myadm05", "myadm05",
{'RaiseError' => 1});
# Drop table 'foo'. This may fail, if 'foo' doesn't exist.
# Thus we put an eval around it.
eval { $dbh->do("DROP TABLE foo") };
print "Dropping foo failed: $@\n" if $@;
# Create a new table 'foo'. This must not fail, thus we don't
# catch errors.
$dbh->do("CREATE TABLE foo (id INTEGER, name VARCHAR(20))");
# INSERT some data into 'foo'. We are using $dbh->quote() for
# quoting the name.
$dbh->do("INSERT INTO foo VALUES (1, " . $dbh->quote("Tim") . ")");
# Same thing, but using placeholders
$dbh->do("INSERT INTO foo VALUES (?, ?)", undef, 2, "Jochen");
# Now retrieve data from the table.
my $sth = $dbh->prepare("SELECT * FROM foo");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
print "Found a row: id = $ref->{'id'}, name = $ref->{'name'}\n";
}
$sth->finish();
# Disconnect from the database.
$dbh->disconnect(); |