Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP PDO Fatal Error

Posted on 2015-01-26
4
Medium Priority
?
379 Views
Last Modified: 2015-01-27
Hi E's,
I try to access to data base using PDO, but any code that I try always give me this fatal error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file' in /home/pedro/public_html/biblioteca/tutoriais/1243/novo_teste.php:4 Stack trace: #0 /home/pedro/public_html/biblioteca/tutoriais/1243/novo_teste.php(4): PDO->__construct('mysql:host=loca...', 'xxxxxxxxxxxxxx', 'xxxxxxxxxxxx') #1 {main} thrown in /home/pedro/public_html/biblioteca/tutoriais/1243/novo_teste.php on line 4

Open in new window

My last try was:
 <?
$conn = new PDO(
    'mysql:host=localhost;dbname=xxxxxxxxxxx', 'xxxxxxxxxxx', 'xxxxxxxxxxxxxxx'
);
?> 

Open in new window

What do I have to do to stop this error?

The best regards, JC
0
Comment
Question by:Pedro Chagas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 2000 total points
ID: 40571514
Do you have access to the server via a command line?  Possibly ssh access?

If so, use the mysql command line utility.

mysql -u <username -p

You'll be prompted for your password.

Then enter the command in the error message.
SET PASSWORD = PASSWORD('your_existing_password')
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 40571525
Hi @Daniel Wilson thank you,
I have a VPS, I thing I have access to the command line, but if not, I ask to the support for they do that for me.
Just one question, this will affect only one domain, or all my VPS (Virtual Private Server) domains?

~JC
0
 
LVL 32

Expert Comment

by:Daniel Wilson
ID: 40571539
This will affect anything that uses that same username / password on the same MySql server.

In all likelihood, the access methods any other sites you are running will support the hashed password.  But ... without knowing those details I wouldn't promise it.
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 40571623
Hi again, I send a request to the VPS support, and I give you feedback soon.
Thank you.

~JC
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question