2
votes

I am trying to create a login system in laravel. I've updated env. file with a database called kokodb. However, when I run this code 'php artisan migrate' in cmd, I came up with the following error:

In Connection.php line 647:

SQLSTATE[HY000] [2054] Server sent charset unknown to t he client. Please, report to the developers (SQL: selec t * from information_schema.tables where table_schema = kokodb and table_name = migrations)

In Connector.php line 68:

SQLSTATE[HY000] [2054] Server sent charset unknown to t he client. Please, report to the developers

In Connector.php line 68:

PDO::__construct(): Server sent charset (255) unknown t o the client. Please, report to the developers

Can you please help me. I did not find any solution to this problem anywhere else.

5
What version of PHP and Laravel is this?Travis Britz
it was version 5. and now it is it is 7.2.11. but this does not solve the problemALBADI
To clarify, it was PHP 5 and then you installed PHP 7.2.11? If so, have you verified that both your webserver and your command line are now using the new php version?Travis Britz
did you find solotion?Adam Kozlowski
It seems that upgrading PHP has solved the charset problem. however, now I am facing another problem when I am trying to migrate. SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = kokodb andtable_name = migrations).ALBADI

5 Answers

3
votes

What version of PHP are you using?

According to PHP's bugtracker, this should be fixed as of 7.0.19, 7.1.5, and 7.2.0.

https://bugs.php.net/bug.php?id=74461

Arun's links mention a solution of changing the server charset back to utf8, but utf8mb4 really is preferable because it offers full unicode support.

2
votes

make sure you create a database first. then, Make sure that you have correct params when it comes to the database in your .env file. Here scenario for localhost:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306 (this can be different when database changed.)
DB_DATABASE=your_database_name
DB_USERNAME=your_username
DB_PASSWORD=your_pass

also run : php artisan config:cache to clear cache.

it work for me.. good luck

1
votes
<?php

$servername = "localhost";

$username = "root";

$password = "";



try{

    // servername and database name
    // my port no is 3307 check your's
    $conn = new PDO('mysql:host = $servername; dbname=project1; ', $username, $password );


    // set the PDO error mode
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo "Connected Successfully";

}
catch(PDOException $e){

    
    echo "Your Connection failed: ".$e->getMessage();
}


?>
0
votes

Make sure that you have correct params when it comes to database in your .env file. Here scenario for localhost:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_username
DB_PASSWORD=your_pass

After any change in .env use php artisan config:cache in console

Also in config/database.php set

    'charset'     => 'utf8mb4',
    'collation'   => 'utf8mb4_unicode_ci',
    'modes'       => [
                'ONLY_FULL_GROUP_BY',
                'STRICT_TRANS_TABLES',
                'NO_ZERO_IN_DATE',
                'NO_ZERO_DATE',
                'ERROR_FOR_DIVISION_BY_ZERO',
                'NO_ENGINE_SUBSTITUTION',
            ],

Then also: php artisan config:cache

Good luck!