Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

joha's avatar
Level 1

Access denied for user 'root'@'localhost'

I uploaded all laravel 5.2 project to a hosting. I changed connection to database in .env file, i changed public direction but when i load a site it shows me an error SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) ================== at Connector->createConnection('mysql:host=127.0.0.1;port=3306;dbname=surdotalker', array('driver' => 'mysql', 'host' => '127.0.0.1', 'port' => '3306', 'database' => 'surdotalker', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'engine' => null, 'name' => 'mysql'), array('0', '2', '0', false, false)) in MySqlConnector.php line 24 =========== at MySqlConnector->connect(array('driver' => 'mysql', 'host' => '127.0.0.1', 'port' => '3306', 'database' => 'surdotalker', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'engine' => null, 'name' => 'mysql')) in ConnectionFactory.php line 61

===== env file DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=host1680244 DB_USERNAME=host1680244 DB_PASSWORD=a3ec8d8c

========== what should i do help me ..... maybe something wrong with host ? I am using hostland.ru

0 likes
4 replies
arukomp's avatar

you need to update your database connection variables, like DB_HOST, DB_USER, etc. You can most likely get them from your hosting's control panel.

calder12's avatar

It honestly looks like your .env file is the wrong one. Are you positive those are the values on your server's .env?

No where in the Laravel code does it set default user/password to root and a blank password, the only place it can be getting those settings is from the .env or if you hard-coded them in config/database.php

Double check the .env on the server and that file.

PS. If those values you posted for the DB connection are real change the password, now!

jlrdw's avatar

Also go to phpmyadmin and see if you can access the database. Report back

joha's avatar
Level 1

no an error is the same , could someone repair my work in server (hosting), and tell me what was the reason I will give you login and parol

Please or to participate in this conversation.