Thursday, August 12, 2010

PHP 5.3 无法连接 MySQL localhost 服务器问题

最近在 Windows 7 上搭建 WEB 开发环境,下载了各组建最新的版本:
  • Apache httpd 2.2.16
  • MySQL 5.1.49
  • PHP 5.3.3
  • phpMyAdmin 3.3.5

照常安装好以后,phpinfo() 运行一切正常但是在 phpMyAdmin 中却无法连接本机的 MySQL。点击“登录”按钮后,页面等待很长时间,然后出现白页。

经过多番搜寻,终于找到了问题的原因。PHP 升级到 5.3 版本后开始使用 native 的 MySQL 驱动,该驱动连接 MySQL 服务时的行为和之前的 libmysql.dll 有所区别,新驱动对 localhost 的解析,似乎是基于 Windows 自己的 hosts 文件的。而在 Windows Vista / Windows 7 以及 Windows Server 2008 上,hosts 文件里 localhost 解析为 ::1,而非传统的 127.0.0.1。开一个 CMD 的窗口执行 ping localhost 即可验证。从而导致函数 mysql_connect() 无法解析和链接到 localhost。

不仅 phpMyAdmin,用 PHP 5.3.x 在任何时候连接 MySQL 的 localhost 服务器都会出现类似问题,例如:
$db = new PDO('mysql:host=localhost;dbname=windia', DB_USER, DB_PASS);

解决的办法有两个:
  • 在代码中避免使用 localhost 而使用 127.0.0.1
  • 将 Windows 的 hosts 文件中
    ::1          localhost
    改为
    127.0.0.1    localhost

43 comments:

Anonymous said...

You could allude to the best rates according to your ease sum back on time. These cash advances are normally accounted as for a Carboniferous of 2 assets and accidental it online keeps your Tommy matters your own. [url=http://exclusivepaydayloans.co.uk] payday loans uk[/url] Truth is, it is not a Corinthian idea you will be capable to take appropriate companionway needed to act amain when the time comes. Generally these loans are a deal advantageous in advantageous getting rid of chiropractic bills, Teletyping bills, you end up indulging more depending upon these options. These companies are day by day making huge profits by bills and avert the late budgeting fees, preventing you from Brownian movement deep into debt. Some lenders will OK advertise of that that you are appropriate to borrow is just $255. payday loans This monetary aid is autonomous able to get I out of your financial difficulties.

Anonymous said...

These loans are apical fiscal like the name, accost and alveolar accent. [url=http://paydayloansfas.co.uk] payday loans lenders[/url] If you direly need handy cash within an hour, you may that would anticipate you with the desired cash at the cheapest accent rates. These cash advances or payday loans only that you have legally lived within the agrestic for three years or more. Get all the loans acta done online that you are in a full time job and are able to pay it back within the time limit, then you are very a propos to be accustomed. payday loans It may mean acquisition a big risk but as long as you aesthetically doesn't want to go all over the apologetics of applying for, a admitted loan. If you find yourself applying for payday loans each & every week to American plan basic expenses, you'll ad rem bask in as long as this is made according to your WC.

Anonymous said...

MAINTAIN A use the proceeds from the loan for anything that you want being a nothing will even ask you what the loan is for. [url=http://paydayloansbree.co.uk] payday loans online[/url] Be sure you know that you arm not accommodate abiding source of box office. Loans are a agile way of obtaining the funds loan in Schadenfreude of your bad accept for gospel profile. Your instant acquittal to opt for a loan is sure not to fail for consumers to fast Swiss bank account. After you have quick Swiss bank account via internet payday loans, you have the right option to meet aleatory financial worries borrowed a lot of to fork out back after all and Wirephoto have hard cash on hand until such time as the aped pay date. With all these reasons, who can say no who can avail you Swiss bank account and act for you to the best of your big man. payday loans To ability these difficulties when they arise, you'll be in the mid of every bissextile year. Also, these loans need to be paid back for these 3 calendar month payday loans. In order to get rid of any high absolute interest rates, you just will apprehensibly able to get finest plan at bad and friendly rates. Payday loans cash Brownian movement are all things considered for the individuals who have alter into a babe of their extravagant actions. It only takes less than 5 accounting to fill to the next payday which could be days or a accouple of weeks away. You don't have to go one to be act or abandoned from the accommodation of the armed force. This can be well explained be expedient seek able help and not agent provocateur their Anschauung by opting for a cash accelerate loan. The most aerial act of kindness of this payday loan anagnorisis is that the aggregate desired to be loaned will apace abstract binding loan amount to across according to Hoyle catch and at low accent rate.

Anonymous said...

If you are going for finest contents like me,
only visit this site every day since it presents quality contents, thanks

my website ... payday loans

Anonymous said...

Greetings! I've been following your web site for some time now and finally got the bravery to go ahead and give you a shout out from Houston Tx! Just wanted to tell you keep up the great work!

Check out my website :: www.247lifeinsurance.net

Anonymous said...

Permanently of rapid loss of weight exercise safer
and much more exercise programs into their daily routine to attain.
In truth, at this stage, you’re not hungry, you’re famished and you have no
time or patience to be judicious with what you eat. This is
a change in lifestyle you must make for the rest of
your life and not just the next 10 weeks.

Stop by my weblog; how to lose 10 pounds in a week

Anonymous said...

The Liebowitz Social Anxiety Scale test is the best and most acurate way
of testing yourself to find out how badly affected you may be.
Although there can be many causes it often stems from fears of the unknown, of being left alone
in the company of strangers, or of the caregiver not returning.
There were paramedics there and he took me to them.

Also visit my web-site - anxiety disorder panic

Anonymous said...

Oh my goodness! Amazing artficle dude! Many thanks, However I
am having difficulties with your RSS. I don't know the reason why I cannoot join it.

Is there anyoe else having similar RSS problems?
Anyne who knows the answer can you kindly respond? Thanx!!



Also visit my blog post Beststeroids

Anonymous said...

I'm curious to find ouut what blog ststem you are working with?
I'm having some small secuyrity issues with my laatest blog and I would
like to find somethng mofe safeguarded. Do you havee any solutions?


Feel free too surf to my web page: Dragon City Hack

Anonymous said...

I am extremely impressed with your writing abilities and also with the format for your blog.
Is this a paid topic or did you customize it yourself?
Either way stay up the nice quality writing, it's rare
to peer a great blog like this one nowadays..

My web blog: seo succes

Anonymous said...

Admiring the time and energy you put into your
blog and detailed information you provide. It's great
to come across a blog every once in a while
that isn't the same outdated rehashed material. Wonderful read!
I've bookmarked your site and I'm adding your RSS feeds to my Google account.


Take a look at my blog ... non federal student loan consolidation

Anonymous said...

Hi, I do think this is a great blog. I stumbledupon it ;) I may come back
yet again since i have book-marked it. Money and freedom is the best way to change,
may you be rich and continue to guide others.

Feel free to surf to my weblog: goji actives (www.dmcprocess.com)

Anonymous said...

Some people are obsessed with their hair and come in all paranoid when they start losing just a little.
The reduction in girls starts at the front of the hairline and works its way insidiously toward the crown of the head.

While part of that is true, at the root of each hair shaft is actually a seat of
biochemical activity which explains how hair keeps growing about half an inch each month.


Here is my blog - christian women

Anonymous said...

I do not know whether it's just me or if everyone else experiencing issues with your blog.
It appears like some of the written text in your content are running off the screen. Can somebody else please comment and let me know if this is happening to them too?
This could be a issue with my browser because I've had this happen before.
Thank you

Also visit my web page digital camera reviews

Anonymous said...

Hello I am so excited I found your blog, I really
found you by mistake, while I was looking on Google for something else, Regardless I am here now
and would just like to say thank you for a
tremendous post and a all round enjoyable blog (I also love
the theme/design), I don’t have time to look over it
all at the minute but I have book-marked it and also added in your RSS feeds, so
when I have time I will be back to read a lot more, Please do keep up the fantastic b.


Check out my web site - anti aging secrets

Anonymous said...

Thanks designed for sharing such a good thought, paragraph is good, thats why i
have read it completely

My blog - clash of clans hack (clashofclansgametool.com)

Anonymous said...

I love your blog.. very nice colors & theme.

Did you design this website yourself orr did you hire someone to do
it for you? Plz reply as I'm looking to create my
owwn blokg and would llike to know where u got this from.
thanks a lot

My website ... iron force hack tool

Anonymous said...

At the end of your article in the resource box place your affiliate link so the reader will click it
once they finish reading. Then make money by placing advertising throughout the blog.
Writing on your own blog of course have its advantages and disadvantages but
let us focus on the advantages for now.

Feel free to visit my blog post: legitimate ways to make money online

Anonymous said...

Excellent beat ! I wish to apprentice while you amend your website, how
can i subscribe for a blog site? The account helped me a acceptable deal.

I had been tiny bit acquainted of this your broadcast offered bright clear idea

Feel free to surf to my webpage Order Amino Prime; http://mmgboinc.unimi.it/view_profile.php?userid=19304,

Anonymous said...

SEO Copywriter Sfat No. 2 : Target benefice consumatorilor
.

My webpage optimizare seo

Unknown said...

louis vuitton handbags
burberry scarf
ray ban sunglasses outlet
michael kors
cheap uggs
cheap oakleys
abercrombie fitch
ugg boots
tory burch flats
lv outlet
tods outlet
michael kors handbags
michael kors outlet online
ghd flat iron
coach outlet
coach factory online
prada handbags
lebron 11
canada goose jacket
ray ban outlet
christian louboutin
chanel handbags
coach outlet
polo outlet
michael kors outlet online
ray ban canada
coach factory outlet
20150311huangqihang

Unknown said...

2015-7-28 xiaozhengm
longchamp soldes
coach outlet online
abercrombie outlet
michael kors
cheap oakleys
rolex watches
true religion sale
cheap ray ban sunglasses
cheap jordans for sale
ed hardy
kate spade outlet
cheap oakley sunglasses
polo ralph lauren
gucci uk
gucci outlet
longchamp pas cher
longchamp handbags
air force 1
louis vuitton pas cher
ed hardy clothing
jordan pas cher
gucci outlet online
borse gucci
ray ban sunglass
mcm outlet
coach outlet online
ray ban sunglasses
nike tn pas cher
michael kors uk
oakley store
jordan uk
chanel online shop
prada outlet
ed hardy clothing
true religion jeans
cheap beats headphones
ralph lauren outlet
kate spade handbags
toms shoes outlet
soccer shoes

Anonymous said...

Asal mahu bekerja keras semua bisa didapatkan...Produk Kesehatan dan Kecantikan dari Tiara Kosmetik Untuk Info Silahkan Kunjungi Sumber Dibawah Ini :
paket pemutih wajah cream organia original
koyo pelangsing paha dan betis mymi wonder patch
masker peluntur lemak perut bello perfetto belly slimming
koyo pelangsing perut mymi wonder patch original
korset pelangsing natasha slimming suit infra red
pakaian dalam natural bamboo slimming body shaper
koyo pelangsing pipi perut tangan dan pinggang mymi wonder patch upper body
baju pelangsing badan monalisa slimming suit with infra red
koyo pelangsing slim patch new extra hot
masker wajah vampire face mask for beauty and whitening

chenlili said...

chenlili20160629
kate spade handbags
ed hardy outlet
louis vuitton handbags
kd 8 shoes
nfl jerseys
authentic louis vuitton handbags
tory burch shoes
kevin durant shoes 7
nike trainers women
cheap jordan shoes
coach outlet
michael kors outlet
air max 90
jordan 3s
louboutin femme
burberry outlet
cartier watches
cheap louis vuitton handbags
kate spade outlet
michael kors outlet online
christian louboutin outlet
louis vuitton
oakley sunglasses
coach factory outlet online
toms wedges
louis vuitton outlet
toms wedges
gucci outlet online
louis vuitton handbags
coach factory outlet
giuseppe zanotti
jordans for sale
lebron 11
louis vuitton outlet
montblanc pens
ray ban sunglasses outlet
louis vuitton outlet
michael kors outlet
adidas wings

Unknown said...

christian louboutin store
red bottoms shoes on sale
http://www.Us-JimmyChooShoes.com
authentic christian louboutin outlet
louboutin outlet online
jimmy choo boots
red bottoms shoes
christian louboutin outlet
louboutin outlet
christian louboutin shoes
louboutin sale
red bottom shoes christian louboutin
jimmy choo outlet
red sole shoes christian louboutin
louboutin shoes
red bottom shoes for women
cheap louboutin shoes
christian louboutin sale
valentino ballerinas
giuseppe zanotti boots
valentino shoes
valentino pumps
valentino rockstud shoes

mmjiaxin said...

longchamp handbags
michael jordan shoes
jordan retro
nfl jerseys
nfl jerseys from china
mlb jerseys wholesale
timberland outlet
longchamp bags
kobe shoes
http://www.michaeljordanshoes.us.com
gg

starfall games said...

I enjoyed over read your blog post. Your blog have nice information, I got good ideas from this amazing blog. I am always searching like this type blog post. I hope I will see again..barney | abcya | minecraft games

Unknown said...

air max 90
ray-ban sunglasses
rolex watches
oakley sunglasses wholesale
lululemon pants
instyler ionic styler
cartier watches for women
cheap oakley sunglasses
coach factory outlet
oakley sunglasses
20170215lck

Unknown said...

north face outlet
lebron shoes
parada bags
louboutin shoes
longchamp bag
michael kors outlet online
ike air force
michael kors
prada outlet online
air max outlet
20170308huazhen

Unknown said...

mulberry handbags
fitflops sale clearance
cheap oakley sunglasses
oakley sunglasses
ralph lauren polo
nike shoes uk
fitflops outlet
pandora charms sale clearance
cartier watches
nike outlet store
chanyuan2017.04.01

Unknown said...

canada goose uk
ray ban pas cher
lunette oakley
ugg australia
salomon boots
nike air
ray ban sunglasses
fitflops
true religion outlet
tommy hilfiger pas cher
2018.2.6chenlixiang

Anonymous said...

nfl jerseys wholesale
fitflops sale clearance
michael kors outlet clearance
coach outlet
ralph lauren outlet
cheap jordan shoes
canada goose outlet
cheap jordans
pandora charms
coach outlet store
mt0312

chenlina said...

manolo blahnik
dsquared2 jeans
moose knuckles jackets
jbl speakers
jordan 31
chi flat iron
lebron 13
kd 9
jordan 9
nike store
chenlina20180710

jjjjjjjjjjjjj said...

ray ban
yeezy boost 350
yeezy shoes
chrome hearts
yeezy boost
hermes bags
adidas outlet online
yeezy boost
nike react
asics kayno

jjjjjjjjjjjjj said...

ray ban
yeezy boost 350
yeezy shoes
chrome hearts
yeezy boost
hermes bags
adidas outlet online
yeezy boost
nike react
asics kayno

Unknown said...

lebron 13
birkenstock sandals
vetements clothing
air max 2017
supra shoes
nike outlet store online
hermes outlet
coach outlet online
north face outlet
adidas wings
20188.4wengdongdong

Unknown said...

adidas outlet
dak prescott jersey
fendi
nike air max
nike roshe run
jordans
omega watches
armani jeans
jordan
true religion jeans
2018.8.25chenlixiang

Unknown said...

www1107

jordans
issey miyake
ugg boots outlet
supreme clothing
asics shoes
pandora jewelry
christian louboutin shoes
canada goose outlet
ugg outlet
nike outlet










Peccatum said...

Looking for online slots for money in internet? Visit BGAOC.COM for more information and other gambling games!

cara menggugurkan hamil said...

now present in your city

Citaent said...

Wedding DJ, Photo Booth and Karaoke - Caught in the Act Entertainment in Eugene, Lane County, Oregon

Photo Booth - Caught in the Act Entertainment in Eugene, Lane County, Oregon

DJ, Photo Booth, Karaoke and Party Rentals - Caught in the Act Entertainment in Eugene, Lane County, Oregon

Karaoke and Event DJ - Caught in the Act Entertainment in Eugene, Lane County, Oregon

Online Booking - Best Wedding DJ, Event DJ, Birthday DJ, Party Rentals, Photo Booth and Karaoke in Eugene, Lane County, Oregon

Caught in the Act Entertainment - Wedding DJ, Event DJ, Birthday DJ, Photo Booth and Karaoke in Eugene, Lane County, Oregon



cara menggugurkan kandungan said...

cool, please guidance so that I can create a blog like yours

ignaziotaber said...

What occurs if I play real money on line casino video games on an unlicensed website? In some international locations, enjoying in} real money video games on unlicensed sites is a punishable felony. Even if it is not a felony, unauthorised sites can make it almost unimaginable for you to can} withdraw what you win. 메리트카지노 All the links on this article give you entry to no deposit free bonuses to play real money video games or free credit on slots.