Core UI - Laravel -> Setting Up - php

I'm trying to make Core UI - Laravel work on my localhost (https://github.com/taboritis/coreui-laravel).
I have followed the steps. I can get to the login screen. I have created the John Doe user by running php artisan migrate:fresh --seed, and I also made the migrations.
I've tried to log in, but every time, I get this error:
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost'
(using password: YES) (SQL: select * from users where email =
john.doe#example.com limit 1)
My .env file looks like this:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=coreui
DB_USERNAME=root
DB_PASSWORD=root
My config/database.php file looks like this:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'coreui'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'root'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
I'm kind of stuck here. What should I do next?

Solved: For some reason I had to restart the web server and after several php artisan config:clear finally worked. Thanks everyone for your comments. You are all upvoted.
Happy coding!

The password is 321ewq , as you can see in
coreui-laravel/database/seeds/UsersTableSeeder.php
GitHub link of the user seeder
Edit
The documentation suggests you to put this configuration in your .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=coreui
DB_USERNAME=root
DB_PASSWORD=
But your .env file looks like:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=coreui
DB_USERNAME=root
DB_PASSWORD=root
Restart a web server and run this command:
php artisan config:clear

Related

Keep on getting a php artisan migrate error on laravel while using a MAMP server?

I am using a MAMP server to host my laravel project. I am trying to push my database migrations table which I have created to the MAMP phpmyadmin database hosted on the localhost 8888 server.
However everytime I use the command , php artisan migrate I get this error:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
I have tried everything to change stuff in the .env file and the database.php file but nothing seems to be changing.
This is what my .env file looks like(only relevant parts):
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:H5A9PbNQk0we6UJnNzSZ68Y22B88SK6wCEq2wachQfE=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME="root"
DB_PASSWORD="temp"
UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
This is what my database.php file looks like:
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', 3306),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'temp'),
'unix_socket' => env( 'DB_SOCKET','/Applications/MAMP/tmp/mysql/mysql.sock'),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
Here is a picture of what the user accounts look like, what I have available:
Make sure u use the right username and password in phpmyadmin
And replace them in .env file and config/database.php file
Try running php artisan config:clear and also php artisan cache:clear.
If that won't help try and login to the database using command line or bash if the credentials work.

SQLSTATE[HY000] [1049] Unknown database 'ictinder'

So for some reason I get this error in my browser when using Laravel. I feel like I got everything set up correctly:
This is my .env file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=ictinder
DB_USERNAME=root
DB_PASSWORD=secret
This is my database.php file:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'ictinder'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'secret'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
This is a screenshots from my phpMyAdmin, it's Dutch so if you don't understand something, let me know
This is what the error looks like in my browser
Thank you for taking your time to help out, or at least read my question!
EDIT 1:
I already tried php artisan cache:clear and php artisan config:clear, both didn't work. I can use php artisan migrate.
If you are using vagrant to run your project. you have to change your db port into 33060 and change your db username into homestead
if you are running your program using php artisan serve, your db port should be 3306 into your db username
see the docs laravel homestead
Hope this can help you
What you need to do in your case is to remove the ictinder from your database and also from your .eve file. then recreate the ictinder again from where it was been remove, it's adventurous to leave the empty DB_PASSWORD like this DB_PASSWORD=, if your MySQL does not have a password, also remember that
If you are using the PHP's default web server (e.g. php artisan serve) you need to restart your server after changing your .env file values.

Laravel 5 - SQLSTATE[HY000][1045] Access denied for user 'root'#'localhost' (using password: NO)

I am trying to make CRUD operations in laravel and I alway have this error message. I already configured the .env and the config/database.php files to my local setting but it doesn't work.
I tried php artisan cache:clear,php artisan config:clear too...
My config/database.php:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', ''),
'database' => env('DB_DATABASE', 'feki_test'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
My .env:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=
DB_DATABASE=feki_test
DB_USERNAME=root
DB_PASSWORD=
I was facing the same issue. But I found the solution by deleting the config.php file saved in the bootstrap/cache/config.php. After that simply run these commands
php artisan config:clear
php artisan cache:clear
php artisan config:cache
Based on the comments, you're trying to access the local xampp mysql server from within Homestead. This won't work as the application is in an isolated virtual machine. You will need to use Homestead's mysql server for your application. Use the default connection information for this.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
To access Homestead's server on your local machine change the port to 33060. This can be helpful if you want to use a SQL tool to connect to the database.
First of all, you need not write credentials in config/database.php.
then delete you .env file and then rename your .env.example file to .env
afterward run the PHP artisan key:generate command on your terminal .
give your database credential.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=feki_test
DB_USERNAME=root
DB_PASSWORD=
and the last restart your development server.
.
In .env and config->database.php file
Instead of this
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=feki_test
DB_USERNAME=root
DB_PASSWORD=
Use this
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=root
DB_PASSWORD=''
and then restart your server. It will work for sure
i changed 127.0.0.1 to localhost And its worked
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=efaf
DB_USERNAME=root
DB_PASSWORD=

Laravel & phpMyAdmin - pdoexception no connection could be made because the target machine actively refused it

I'm using Laravel 5.2 and phpMyAdmin (which I'm running through InstantWordpress) and when I try to migrate the database I get this error message from the command line:
[PDOException]
SQLSTATE[HY000] [2002] no connection could be made because the target machine actively refused it
This is what my .env file looks like:
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:IBh/yuGAXTC2a2rRD7A9VE5io7AbPXLYfJUfLyFnRfA=
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=micedb
DB_USERNAME=roo
DB_PASSWORD=roo
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
Then, when I look at the app in the browser I have a landing page as though the initial migrate has worked but there's nothing in the database and when I try to register I get an error message and stack trace.
In Config->database
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'DBName'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
In .env file :
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=DBName
DB_USERNAME=root
DB_PASSWORD=
Close the laravel application server and restart again for clearing the cache.
php artisan serve
Try this. Good luck!

how to connect to db with laravel 5

I updated my laravel4 to laravel5 now my problem is i cant connect to database
My mysql
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'lue'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ' '),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
i returns this problem
PDOException in Connector.php line 47:
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES)
help :)
You need to edit your .env file in the root of your application and change the DB username and password there
Make sure you are editing the .env file, and not a .env.php file. In Laravel 4 there was a way to use .env.environment.php but in Laravel 5 it's all done with a .env file (note that it doesn't have a php suffix)
Also the data in the .env file must not be in the array format. It should just be as follows:
APP_ENV=local
APP_DEBUG=true
APP_KEY=longstring
DB_HOST=localhost
DB_DATABASE=dbname
DB_USERNAME=homestead
DB_PASSWORD=secret
I had the same problem and this is how I fixed it.Go to the root of your laravel folder (application folder) in my case it is C:\firstapp and open .env file in notepad++ Update the following code accordingly.
DB_HOST=localhost
DB_DATABASE=firstapp (this is database name)
DB_USERNAME=root (user name)
DB_PASSWORD= (password , leave empty if none , do not even put "")
Important
and then restart your application like this php artisan serve (using command line) while you are in the root of you application folder. See this image for clarification link.
You need to edit your .env file in the root of your application. Just configure as following example:
APP_ENV=local
APP_DEBUG=true
APP_KEY=6CqAQJdOd8oKoh0NhbefkmS0Pd8FDH6h
DB_HOST=localhost
DB_DATABASE=your database name
DB_USERNAME=your database user name
DB_PASSWORD=your password
CACHE_DRIVER=file
SESSION_DRIVER=file

Categories