Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP PDO Fatal Error

Posted on 2015-01-26
4
Medium Priority
?
387 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
  • 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

Industry Leaders: 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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

782 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