Can't connect to [local] MySQL server

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
8/29/2005 6:37:57 PM
Gravatar
Total Posts 3

Re: Can't connect to [local] MySQL server

i installed mojoportal on a mac os x tiger 10.4.2

* Mono.Framework 1.1.8
* Apache 2.0.54
* xsp 1.0.9
* mod_mono 1.0.9
* MySQL 4.0.21



all its ok
but my connection to mysql server fail

Unhandled Exception: MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts
in <0x007e4> MySql.Data.MySqlClient.NativeDriver:Open ()
in <0x0004c> MySql.Data.MySqlClient.Driver:Create (MySql.Data.MySqlClient.MySqlConnectionString settings)
in <0x000f4> MySql.Data.MySqlClient.MySqlPool:CreateNewPooledConnection ()
in <0x002fc> MySql.Data.MySqlClient.MySqlPool:GetPooledConnection ()
in <0x00060> MySql.Data.MySqlClient.MySqlPool:GetConnection ()
in <0x00190> MySql.Data.MySqlClient.MySqlPoolManager:GetConnection (MySql.Data.MySqlClient.MySqlConnectionString settings)
in <0x00068> MySql.Data.MySqlClient.MySqlConnection:Open ()

the version of mysql is 4.0.21, help me!, from navicat i can connect to the database mojoportal.
8/30/2005 1:55:23 PM
Gravatar
Total Posts 18439

Re: Can't connect to [local] MySQL server

Hi Juan,

Did you set a good connection string in the Web.config file?
Usually this error is one of 2 things, either MySQL is not configured for tcp/ip connections or the hostname can't be resolved. If the web server is the same machine as the MySQL box put localhost for the server name or try 127.0.0.1

Hope it helps,

Joe
8/30/2005 3:51:17 PM
Gravatar
Total Posts 3

Re: Can't connect to [local] MySQL server

thanks Joe but...

my connection string it's correct
Data Source=localhost;Database=mojoportal;User ID=root;Password=123;

i can connect to database from navicat and mysql command line

ibook-g4-de-juan-manuel:/usr/local/apache2/htdocs/mojoportal/bin root# /usr/local/mysql/bin/mysql -h localhost -u root -p
Enter password:
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 10 to server version: 4.0.21 Complete MySQL by Server Logistics

Type help or \h for help. Type \c to clear the buffer.

mysql


i try

telnet localhost 3306
Trying 127.0.0.1...
Connected to localhost.
Escape character is ^.

4.0.21 Complete MySQL by Server Logistics

and it's ok

i do a test program

using System;
using MySql.Data;
using MySql.Data.MySqlClient;

class Test
{

public static void Main( string[] args )
{
Console.WriteLine(abriendo base de datos...)
MySqlConnection connection = new MySqlConnection(Data Source=localhost
Database=test;User ID=root;password=123;};
connection.Open();
connection.Close();
Console.WriteLine(cerrando base de datos...);
}

}

to test the connection but the error is the same

ibook-g4-de-juan-manuel:/usr/local/apache2/htdocs/mojoportal/bin root# mono mysqltest.exe
abriendo base de datos...

Unhandled Exception: MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts
in <0x007e4> MySql.Data.MySqlClient.NativeDriver:Open ()
in <0x0004c> MySql.Data.MySqlClient.Driver:Create (MySql.Data.MySqlClient.MySqlConnectionString settings)
in <0x000f4> MySql.Data.MySqlClient.MySqlPool:CreateNewPooledConnection ()
in <0x002fc> MySql.Data.MySqlClient.MySqlPool:GetPooledConnection ()
in <0x00060> MySql.Data.MySqlClient.MySqlPool:GetConnection ()
in <0x00190> MySql.Data.MySqlClient.MySqlPoolManager:GetConnection (MySql.Data.MySqlClient.MySqlConnectionString settings)
in <0x00068> MySql.Data.MySqlClient.MySqlConnection:Open ()


also try with 127.0.0.1

my hosts file

ibook-g4-de-juan-manuel:/etc root# more hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.? Do not change this entry.
##
127.0.0.1 ocalhost
255.255.255.255 broadcasthost

192.168.0.1 z7.mshome.net

any other solution.
8/30/2005 4:07:45 PM
Gravatar
Total Posts 18439

Re: Can't connect to [local] MySQL server

What port is MySQL running on? Normally it is 3306 but I have heard of cases where it was running on port 3308 try adding port=3308 in your connection string.

I don't know anything about navicat but when you connect from the command line I don't think it is using tcp/ip connections so I'm not convinced you have MySQL configured for tcp/ip connections.
Check the MySQL documentation about configuring it to accept tcp/ip connections.

Joe
8/31/2005 7:56:32 AM
Gravatar
Total Posts 36

Re: Can't connect to [local] MySQL server

What I think is happening here is, it's trying to connect via socket. Traditionally I believe if you specify localhost in comparison to 127.0.0.1 the mysql driver will look for a socket, but if you specify an ip or include in the connection string a port number you'll be able to connect via tcp/ip.

An example connection string would be:
Data Source=localhost;Port=3306;Database=mojoportal;User ID=root;Password=123;
or possibly (port added in this example just to be on the safe side)
Data Source=127.0.0.1;Port=3306;Database=mojoportal;User ID=root;Password=123;

also here is some information about connection strings from mysql about their connector.
9/1/2005 1:53:31 PM
Gravatar
Total Posts 3

Re: Can't connect to [local] MySQL server

somebody that has installed mojoportal (with mysql) in mac os x  tiger.

say me the version of mysql and kind of installation.

thanks.
You must sign in to post in the forums. This thread is closed to new posts.