Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 database issue

Tags:

I've installed laravel 5 successfully by using this command:

composer create-project laravel/laravel test-laravel-5-project dev-develop --prefer-dist 

I even verified the version of installed laravel by using php artisan -V command. The output was

Laravel Framework version 5.0-dev 

Then I went to app/config/database.php, gave dafault db as mysql and gave configurations as

'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'Logintestfive'), 'username'=> env('DB_USERNAME', 'root'), 'password'=> env('DB_PASSWORD', 'manasa'), 'charset'=> 'utf-8', 'collation'=> 'utf-8_unicode_ci', prefix=> '', 'strict'=> false, ] 

Then I went to localhost:8000/auth/register and filled up the form and submitted the data and this is the error which I got:

PDOException in Connector.php line 47: SQLSTATE[28000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) 

But I've neither used laravel homestead for installng laravel 5 in my system nor used vagrant to set up laravel homestead. And it tells me like this:

in Connector.php line 47 at PDO->__construct('mysql:host=localhost;dbname=homestead', 'homestead', 'secret', array('0', '2', '0', false, '0')) in Connector.php line 47 at Connector->createConnection('mysql:host=localhost;dbname=homestead', array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, '0')) in MySqlConnector.php line 20 at MySqlConnector->connect(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in compiled.php line 10545 at ConnectionFactory->createSingleConnection(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in compiled.php line 10541 at ConnectionFactory->make(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false), 'mysql') in compiled.php line 10459 

How can I fix those issues?

like image 866
Ajay Kulkarni Avatar asked Jan 29 '15 07:01

Ajay Kulkarni


People also ask

How check Laravel database connected or not?

Echo the Laravel database name in Blade/PHP This will output the name of the database or return 'none' if there is no connection. If you view it in the browser, it gives you the name of the connected database. Checking whether the application is connected to a Laravel database.

Can Laravel work with SQL Server?

Laravel makes connecting with SQL Server database and running queries extremely simple out of the box. The SQL Server, MSSQL database configuration for your application is located at Laravel Project Root Folder, config/database.


1 Answers

I got a similar problem. I started my server using php artisan serve command, and edited the .env file and refreshed the web-page which did not reflect any changes!

I fixed it by stopping the webserver, editing the .env.php file and restarting the webserver!

So I guess it's a caching-issue of the .env.php file.

like image 199
Yordi Uytersprot Avatar answered Oct 09 '22 23:10

Yordi Uytersprot