Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The server requested authentication method unknown to the client [caching_sha2_password] #1

Closed
al77ex1 opened this issue Mar 24, 2018 · 7 comments

Comments

@al77ex1
Copy link

al77ex1 commented Mar 24, 2018

  1. I created the entity.
<?php
//
// src/Entity/Post.php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="App\Repository\PostRepository")
 */
class Post
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=128)
     */
    protected $name;

    /**
     * @ORM\Column(type="string", length=128)
     */
    protected $last_name; 
    
    /**
     * @ORM\Column(type="string", length=32)
     */
    protected $phone; 
    
    /**
     * @ORM\Column(type="string", length=32)
     */
    protected $profession; 
    
    /**
     * @ORM\Column(type="decimal", nullable=true)
     */
    protected $age; 
    
    /**
     * @ORM\Column(type="decimal", nullable=true)
     */
    protected $salary; 

    /**
     * @ORM\Column(type="text", nullable=true)
     */
    protected $notice;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    protected $created;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    protected $updated;
}
  1. I execute the command: bin/console doc:sch:crea and after that, the console:
 !                                                                                                                      
 ! [CAUTION] This operation should not be executed in a production environment!                                         
 !                                                                                                                      

 Creating database schema...

2018-03-24T19:52:41+00:00 [error] Error thrown while running command "'doc:sch:crea'". Message: "Schema-Tool failed with Error 'An exception occurred in driver: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client' while executing DDL: CREATE TABLE post (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(128) NOT NULL, last_name VARCHAR(128) NOT NULL, phone VARCHAR(32) NOT NULL, profession VARCHAR(32) NOT NULL, age NUMERIC(10, 0) DEFAULT NULL, salary NUMERIC(10, 0) DEFAULT NULL, notice LONGTEXT DEFAULT NULL, created DATETIME DEFAULT NULL, updated DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB"

In ToolsException.php line 34:
                                                                                                                                                                                               
  Schema-Tool failed with Error 'An exception occurred in driver: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client' while executing DDL: CREATE TABLE   
  post (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(128) NOT NULL, last_name VARCHAR(128) NOT NULL, phone VARCHAR(32) NOT NULL, profession VARCHAR(32) NOT NULL, age NUMERIC(10, 0) DEFAULT   
  NULL, salary NUMERIC(10, 0) DEFAULT NULL, notice LONGTEXT DEFAULT NULL, created DATETIME DEFAULT NULL, updated DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLAT  
  E utf8mb4_unicode_ci ENGINE = InnoDB                                                                                                                                                         
                                                                                                                                                                                               

In AbstractMySQLDriver.php line 121:
                                                                                                                            
  An exception occurred in driver: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client  
                                                                                                                            

In PDOConnection.php line 47:
                                                                                           
  SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client  
                                                                                           

In PDOConnection.php line 43:
                                                                                           
  SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client  
                                                                                           

In PDOConnection.php line 43:
                                                                                                                
  PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] 
@joeymasip
Copy link
Owner

joeymasip commented Mar 24, 2018

Hi @al77ex1 ,

There seems to be a problem with MySql 8.0 forcing new password formats... More info here

Try changing mysql version in docker-compose.yml

from

mysql:8.0

to

mysql:5.6

That should make it work, as MySql 5.6 is a stable version.

Cheers,
Joey

@al77ex1
Copy link
Author

al77ex1 commented Mar 25, 2018

Try changing mysql version in docker-compose.yml
from
mysql:8.0
to
mysql:5.6

now in the console:

 !                                                                                                                      
 ! [CAUTION] This operation should not be executed in a production environment!                                         
 !                                                                                                                      

 Creating database schema...

2018-03-25T15:03:18+00:00 [error] Error thrown while running command "'doc:sch:crea'". Message: "Schema-Tool failed with Error 'An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known' while executing DDL: CREATE TABLE post (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(128) NOT NULL, last_name VARCHAR(128) NOT NULL, phone VARCHAR(32) NOT NULL, profession VARCHAR(32) NOT NULL, age NUMERIC(10, 0) DEFAULT NULL, salary NUMERIC(10, 0) DEFAULT NULL, notice LONGTEXT DEFAULT NULL, created DATETIME DEFAULT NULL, updated DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB"

In ToolsException.php line 34:
                                                                                                                                                                                                
  Schema-Tool failed with Error 'An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known' while executing DDL: CREATE   
   TABLE post (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(128) NOT NULL, last_name VARCHAR(128) NOT NULL, phone VARCHAR(32) NOT NULL, profession VARCHAR(32) NOT NULL, age NUMERIC(10, 0) D   
  EFAULT NULL, salary NUMERIC(10, 0) DEFAULT NULL, notice LONGTEXT DEFAULT NULL, created DATETIME DEFAULT NULL, updated DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4   
   COLLATE utf8mb4_unicode_ci ENGINE = InnoDB                                                                                                                                                   
                                                                                                                                                                                               

In AbstractMySQLDriver.php line 108:
                                                                                                                                   
  An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known  
                                                                                                                                   

In PDOConnection.php line 47:
                                                                                                  
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known  
                                                                                                  

In PDOConnection.php line 43:
                                                                                                  
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known  
                                                                                                  

In PDOConnection.php line 43:
                                                                                               
  PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known 

@joeymasip
Copy link
Owner

Hi again @al77ex1 ,

It seems as if it can't connect to the database. Have you updated the .env file with the parameters from the mysql image?

Here's a guide on how to do this (check step 6)

@al77ex1
Copy link
Author

al77ex1 commented Mar 25, 2018

It works now!

Thank you very much!

@carlosguijarro
Copy link

Where is docker-compose.yml located?

@joeymasip
Copy link
Owner

It's in the project root.

@Anouar-91
Copy link

Bonjour à tous,

je me permet de poster ce commentaire pour donner la solution que j'ai trouvé à cette même erreur que j'ai rencontré aujourd'hui.

Il s'avère que mon problème se trouvait au niveau du fichier .env à la ligne suivante :

DATABASE_URL="mysql://db_user:password@127.0.0.1:3306/dbname?serverVersion=5.7"

Afin de créer une base de donnée en symfony, il est primordial d'adapter cette ligne à votre configuration. Vous devez remplacer db_user par root, password par root pour ceux pour lesquels le mot de passe est root (pour ma part par exemple) ou sinon ne rien mettre, pour certain serveur local il n'a pas de mot de passe. Ensuite à la place de dbname, vous devez mettre le nom que vous voulez donner à votre futur base. MAIS CE N'EST PAS FINI !! Si vous vous contentez seulement de ces modifications, vous rencontrerez la même erreur ou pas ! Pour ma part, j'ai rencontré cette erreur, car je devais aussi changer le numéro de port, qui est initialement 3306, sauf pour ceux qui utilise MAMP (sur mac), le port qu'utilise MAMP pour mysql est 8889. Donc en remplaçant 3306 par 8889 cela fonctionne :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants