Home>

We are currently studying with the book "PHP Framework Laravel Wev Application Development".

For books, we are building sites using Vagrant and Homestead, but due to various circumstances, we would like to build sites with Docker this time.
There is a process of migration using the command "$php artisan migrate" in p34,35 of this document, but this does not work.

The following results are returned when executed in the terminal.

In Connection.php line 664:
  SQLSTATE [HY000] [1045] Access denied for user 'homestead'@'172.22.0.1' (using password: YES) (SQL: select * from information_schema.tables where
   table_schema = homestead and table_name = migrations)

In Connector.php line 67:
  SQLSTATE [HY000] [1045] Access denied for user 'homestead'@'172.22.0.1' (using password: YES)

Actually, the order of this work is

  1. Environment construction with Vagrant and Homestead
  2. Environment construction with Docker and Laradock
  3. Learn later on Docker

We are proceeding with this, and I think that perhaps the reason for this error was that we first built the environment with Homestead.
However, it is difficult to understand how to solve the problem.

Maybe the migration procedure on Docker is different from Homestead = I thought it would be impossible to proceed according to the book procedure. Is it necessary to make SQL connection settings in advance?

The last thing we want to do is create a database and tables to implement the authentication/registration function provided as standard in Laravel.
Excuse me, but if you know someone, I hope you can open the teaching board.

  • Answer # 1

    We are happy to report that we were able to resolve the problem.

    First of all, my premise was missing from my perception, and I didn't share it with you. Excuse me.
    The premise is that you are using laradock.

    Because it was out of my recognition, I was investigating only how to build a laravel environment on Docker without using laradock, so I could not solve it forever.

    Here are the steps that have been taken.


    Step 1:
    First of all, in the order of "Connection setting to MySQL", "Connection to Workspace container", "Use artisan command" in the following site

    * As the original thread, I built the environment with reference to the book "PHP framework Laravel Wev application development", so I replaced the src of the above site with sampleapp and executed it.

    Then, the following error appears (error content has changed).

    In Connection.php line 664:
      SQLSTATE [HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_sche
      ma.tables where table_schema = default and table_name = migrations)
    In Connector.php line 67:
      SQLSTATE [HY000] [2054] The server requested authentication method unknown to the client
    In Connector.php line 67:
      PDO :: __ construct (): The server requested authentication method unknown to the client [caching_sha2_password]

    Step 2:
    To solve the above error, execute "[Solution 2] Change MySQL Authentication Method" in the link below
    https://qiita.com/ntakuyan/items/42cbe7f45e85e16fe639
    * On the way

    ALTER USER 'homestead' @ '%' IDENTIFIED WITH mysql_native_password BY 'secret';


    There is an execution of the SQL statement, but this time I changed 'homestead' to 'default' and executed it to match the setting made in step 1.


    After completing the above, enter workspase again and type the command 'php artisan migrate' ...

    Migration table created successfully.
    Migrating: 2014_10_12_000000_create_users_table
    Migrated: 2014_10_12_000000_create_users_table
    Migrating: 2014_10_12_100000_create_password_resets_table
    Migrated: 2014_10_12_100000_create_password_resets_table

    Done!

  • Answer # 2

      

    Is it necessary to make SQL connection settings in advance in the .env file or something in this case?

    Yes.
    Set DB connection settings for Docker in .env (setting information depends on environment)
    php artisan config: clear
    After destroying the config cache in
    Please run php artisan migrate again