You are here

Home » Blogs » Alex's blog

PHP 5.3 to MySQL connection error

While trying PHP 5.3 today my scripts could not connect to the mysql database. I was sure that everything is installed correctly, so I've searched for similar issues reported by the developers and found the following interesting bug report:

MySQL functions cannot be used with 5.3.x on Vista when using "localhost"

So after changing localhost in my connection strings to 127.0.0.1 PHP successfully connected to the MySQL server. Another workaround is to delete or comment "::1 localhost" record in the c:\windows\system32\drivers\etc\hosts file.

It seems that this problem hits almost all Vista and PHP 5.3 users (Google: Vista PHP 5.3 mysql localhost "127.0.0.1" hosts) but PHP team is not considering this problem as a bug. Definitely, it is excellent demonstration of the open source wold welcomeness to the new users :-)

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or class="OPTIONS" [title="the title"].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Please note that all comments that look like "Thank you! This is exactly what I've looked for! You are THE GREAT! My site with flash games" will be immediately deleted without any compunction and your IP will be reported to mollom and added to the spamlists. Thank you for understanding.

LinkedIn profile
I’m Alex Netkachov and I welcome you on my site, which is my technical playground and web log.