I moved the Laravel project from localhost to the server for which I have done every step.
I am able to view the login page on my server. The problem is I am not able to connect with my MySQL server.
My .env
file:
APP_NAME=Transport
APP_ENV=local
APP_KEY=base64:mrakeyidharhaikonsdf
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=transport_db
DB_USERNAME=root
DB_PASSWORD=mypass
I tried to change the host to 127.0.0.1
and also tried to put my server's IP address. It didn't help me. Am I missing something ?
My error:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select count(*) as aggregate from
users
where
I know this question may have answers already on Stack Overflow. But I have different issue here.
Make sure your database credentials and database host are set correctly:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE="your_database_name"
DB_USERNAME="put_db_user_name _here"
DB_PASSWORD="put_db_password_here_if_have_set"
If you have not set any database password then add:
DB_PASSWORD=""