Offline PHP connection string

Asked

Viewed 458 times

1

I’m trying to connect offline to a Mysql base, but I’m not getting.

The code is on my machine, I’ve tried by IIS and XAMPP but every time I try to connect, it presents an error. Follow the connection string I’m using:

$host = ""; //computador onde o servidor de banco de dados esta instalado
$user = ""; //seu usuario para acessar o banco
$pass = ""; //senha do usuario para acessar o banco
$banco = ""; //banco que deseja acessar

$conexao = mysql_connect($host,$user,$pass);
if (!$conexao)
{
die('Erro: ' . mysql_error());
} else {
echo "Conectou";
}
mysql_select_db($banco);

Follow the error that appears:

Error: 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.

Does anyone know why this happens?

  • Patrick, you posted the question in English on [en.so]. Could you translate? Or the intention was to post on [so] (in English)?

  • Patrick, your connection string is empty. That’s why it returns this error.

1 answer

2

Review your connection information.

Standard information for Mysql connection

Host: localhost or 127.0.0.1

User: root

Password: Default password is blank even

So your default connection would look like this:

$host = "localhost"; //computador onde o servidor de banco de dados esta instalado
$user = "root"; //seu usuario para acessar o banco
$pass = ""; //senha do usuario para acessar o banco
$banco = "test"; //banco que deseja acessar

$conexao = mysql_connect($host,$user,$pass);

Considerations

  1. Consider switching mysql_connect for mysqli_connect
  2. Consider using a class to manage your connection (Connectionmsi)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.