简体   繁体   中英

Laravel 8: SQLSTATE[28000] [1045] Access denied for user (using password: YES)

I just uploaded my website into server and here is my .env file:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_db
DB_USERNAME=my_user
DB_PASSWORD=my_pass

But as soon as I load my website, I get this message:

Illuminate\Database\QueryException SQLSTATE[28000] [1045] Access denied for user 'my_user'@'127.0.0.1' (using password: YES) (SQL: select count(*) as aggregate from users where phone = 11111111)

And here is also the migration of table users :

public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('phone')->unique();
            $table->binary('image')->nullable();
            $table->string('job')->nullable();
            $table->string('location')->nullable();
            $table->string('bio')->nullable();
            $table->string('skills')->nullable();
            $table->string('stackoverflow')->nullable();
            $table->string('github')->nullable();
            $table->string('instagram')->nullable();
            $table->string('linkedin')->nullable();
            $table->string('website')->nullable();
            $table->rememberToken();
            $table->timestamps();
        });
    }

So what is going wrong here? I have created the database and imported tables correctly and also added the privileged user to that.

So if you know how to fix this issue, plz let me know...

Thanks.

I just uploaded my website into server and here is my .env file:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_db
DB_USERNAME=my_user
DB_PASSWORD=my_pass

But as soon as I load my website, I get this message:

Illuminate\Database\QueryException SQLSTATE[28000] [1045] Access denied for user 'my_user'@'127.0.0.1' (using password: YES) (SQL: select count(*) as aggregate from users where phone = 11111111)

And here is also the migration of table users :

public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('phone')->unique();
            $table->binary('image')->nullable();
            $table->string('job')->nullable();
            $table->string('location')->nullable();
            $table->string('bio')->nullable();
            $table->string('skills')->nullable();
            $table->string('stackoverflow')->nullable();
            $table->string('github')->nullable();
            $table->string('instagram')->nullable();
            $table->string('linkedin')->nullable();
            $table->string('website')->nullable();
            $table->rememberToken();
            $table->timestamps();
        });
    }

So what is going wrong here? I have created the database and imported tables correctly and also added the privileged user to that.

So if you know how to fix this issue, plz let me know...

Thanks.

I just uploaded my website into server and here is my .env file:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_db
DB_USERNAME=my_user
DB_PASSWORD=my_pass

But as soon as I load my website, I get this message:

Illuminate\Database\QueryException SQLSTATE[28000] [1045] Access denied for user 'my_user'@'127.0.0.1' (using password: YES) (SQL: select count(*) as aggregate from users where phone = 11111111)

And here is also the migration of table users :

public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('phone')->unique();
            $table->binary('image')->nullable();
            $table->string('job')->nullable();
            $table->string('location')->nullable();
            $table->string('bio')->nullable();
            $table->string('skills')->nullable();
            $table->string('stackoverflow')->nullable();
            $table->string('github')->nullable();
            $table->string('instagram')->nullable();
            $table->string('linkedin')->nullable();
            $table->string('website')->nullable();
            $table->rememberToken();
            $table->timestamps();
        });
    }

So what is going wrong here? I have created the database and imported tables correctly and also added the privileged user to that.

So if you know how to fix this issue, plz let me know...

Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM