Laravel Error Message : access denied for user ‘homestead’@’localhost’ (using password yes)

Posted on

This is an article which is written to display on how to solve the error generated executing a script based on Laravel framework. This is where the error shown when an operation relates with the database connection is being processed in a controller.

access denied for user 'homestead'@'localhost' (using password yes)

Below is the snippet code found in a controller file which is directly need a database connection :

$data = Input::all();

The above snippet code will called and processed every entry inserted in every Input field defined in the blade view template file. Below is the full error message given :

user 'homestead'@'localhost' (using password: YES) (SQL: insert into `user` (`general_info`, `specific_info`, `updated_at`, `created_at`) values (e, f, 2017-05-06 11:29:44, 2017-05-06 11:29:44)

It is a process inserting a record in a certain table and it ends in a failure. The above error can be solved by editing a configuration file named .env which is responsible for defining database connection specifically MySQL Database Connection.

The file named .env is located in the root folder of a web-based application powered by Laravel framework. The file itself contains default MySQL Database connection as shown below :


As it can be seen above, the username is ‘homestead’ and the host is ‘localhost’ which is suitable with the error message generated in database connection process by trying to insert a certain record into a table named ‘user’.

So, in order to resolve the problem generated by an error message as shown in the title of the article, just change the value of the entry given in the environment variable file named ‘.env’ specifically on the database information connection part as shown above.

Below is an example of defining the entry to suit or to match the value of database configuration connection according to the environment of the database server :


Based on the configuration value which is changed as shown above, if it is the right configuration, the process of inserting the record into the destined table will be carried out successfully.

One thought on “Laravel Error Message : access denied for user ‘homestead’@’localhost’ (using password yes)

Leave a Reply