joed86
Jul 22 2008, 07:33 AM
Hi,
I have been getting the folloing error when I go to dashboard in MT 4.12.
Got an error: Connection error: Can't connect to MySQL server on 'mysql' (13) at lib/MT/ObjectDriver/Driver/DBD/mysql.pm line 49
at lib/MT/ObjectDriver/Driver/DBD/mysql.pm line 49
I also get this error when I try to rebuild, go to any of the manage functions.
Sometimes if I continue to refresh or try again, it eventually acts normal without the error.
Please help if you can.
Thanks, Joe
joed86
Jul 22 2008, 07:41 AM
here is the html for the page that is getting the error...
1 # Movable Type ® Open Source © 2001-2008 Six Apart, Ltd.
2 # This program is distributed under the terms of the
3 # GNU General Public License, version 2.
4 #
5 # $Id: mysql.pm 83433 2008-06-18 21:44:24Z bchoate $
6
7 package MT::ObjectDriver::Driver::DBD::mysql;
8
9 use strict;
10 use warnings;
11
12 use base qw(
13 MT::ObjectDriver::Driver::DBD::Legacy
14 Data::ObjectDriver::Driver::DBD::mysql
15 MT::ErrorHandler
16 );
17
18 sub dsn_from_config {
19 my $dbd = shift;
20 my $dsn = $dbd->SUPER::dsn_from_config(@_);
21 my ($cfg) = @_;
22 $dsn .= ':database=' . $cfg->Database;
23 $dsn .= ';hostname=' . $cfg->DBHost if $cfg->DBHost;
24 $dsn .= ';mysql_socket=' . $cfg->DBSocket if $cfg->DBSocket;
25 $dsn .= ';port=' . $cfg->DBPort if $cfg->DBPort;
26 return $dsn;
27 }
28
29 sub sql_class {
30 require MT::ObjectDriver::SQL::mysql;
31 return 'MT::ObjectDriver::SQL::mysql';
32 }
33
34 sub ddl_class {
35 require MT::ObjectDriver::DDL::mysql;
36 return 'MT::ObjectDriver::DDL::mysql';
37 }
38
39 sub configure {
40 my $dbd = shift;
41 my ($driver) = @_;
42 $dbd->_set_names($driver);
43 $dbd;
44 }
45
46 sub _set_names {
47 my $dbd = shift;
48 my ($driver) = @_;
49 my $dbh = $driver->rw_handle;
50
51 my $cfg = MT->config;
52 my $set_names = $cfg->SQLSetNames;
53 return 1 if (defined $set_names) && !$set_names;
54
55 eval {
56 local $@;
57 my $sth = $dbh->prepare('show variables like "character_set_database"')
58 or return $driver->error($dbh->errstr);
59 $sth->execute or return $driver->error($sth->errstr);
60 my $result = $sth->fetchall_hashref('Variable_name');
61 my $charset_db = $result->{character_set_database}{Value};
62 if (defined($charset_db) && ($charset_db ne 'latin1')) {
63 # MySQL 4.1+ and non-latin1(database) == needs SET NAMES call.
64 my $c = lc $cfg->PublishCharset;
65 my %Charset = (
66 'utf-8' => 'utf8',
67 'shift_jis' => 'sjis',
68 'shift-jis' => 'sjis',
69 'euc-jp' => 'ujis',
70 #'iso-8859-1' => 'latin1'
71 );
72 $c = $Charset{$c} ? $Charset{$c} : $c;
73 $dbh->do("SET NAMES " . $c) or
74 return ($dbh->errstr);
75 if (!defined $set_names) {
76 # SQLSetNames has never been assigned; we had a successful
77 # 'SET NAMES' command, so it's safe to SET NAMES in the future.
78 $cfg->SQLSetNames(1, 1);
79 $cfg->save_config;
80 }
81 } else {
82 # 'set names' command isn't working for this verison of mysql,
83 # assign SQLSetNames to 0 to prevent further errors.
84 $cfg->SQLSetNames(0, 1);
85 $cfg->save_config;
86 return 0;
87 }
88 };
89 1;
90 }
91
92 1;
93 __END__
94
95 =head1 NAME
96
97 MT::ObjectDriver::Driver::DBD::mysql
98
99 =head1 METHODS
100
101 TODO
102
103 =head1 AUTHOR & COPYRIGHT
104
105 Please see L<MT/AUTHOR & COPYRIGHT>.
106
107 =cut
108
Su-
Jul 22 2008, 11:34 AM
QUOTE (joed86 @ Jul 22 2008, 10:33 AM)

I have been getting the folloing error when I go to dashboard in MT 4.12.
Got an error: Connection error: Can't connect to MySQL server on 'mysql' (13) at lib/MT/ObjectDriver/Driver/DBD/mysql.pm line 49 at lib/MT/ObjectDriver/Driver/DBD/mysql.pm line 49
There's really not much to go on. The application is failing to connect to the database, which doesn't suggest much other than that your database server is down. Ask your host if they're having any problems.