Solved

PHP PDO Fatal Error

Posted on 2015-01-26
4
355 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 500 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
The viewer will learn how to dynamically set the form action using jQuery.
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now