Solved

PHP PDO Fatal Error

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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 count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

827 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