I have this in my .env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=m6twKy7Lr6KKFvVa7QgXUe78xfn08MLn
DB_HOST=localhost
DB_DATABASE=laravel1
DB_USERNAME=root
DB_PASSWORD=somepass
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
And this is in my database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
The database is created and I can see it in phpMyAdmin in browser.
But when I write php artisan migrate I get this error:
[PDOException]
SQLSTATE[HY000] [1049] Unknown database 'laravel1'
I have seen the answers on
Laravel Migration - Says unknown database, but it is created , but that didn't helped me.
Try specifying the MySQL port that you are using. Might work out. I had a similar issue like this. Be sure to give the appropriate port where MySQL is installed in ur system(default is 3306).
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'databasename'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'root'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
Related
Error: SQLSTATE[HY000] [1044] Access denied for user 'tfs_user'#'localhost' to database 'tfs' (SQL: select * from settings)
When i click login/registration page i'm getting this error. i can't understand what's the problem. I updated my .env file with correct database info.
.env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=tfs
DB_USERNAME=tfs_user
DB_PASSWORD=tfsdemo01
database.php file
'default' => env('DB_CONNECTION', 'mysql'),
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',<
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
],
How can i solve this error, can anyone help me please.
If the mysql server is on the same server as your application use host as localhost
DB_HOST=localhost
I am getting the error
SQLSTATE[HY000] [2002] Operation timed out (SQL: select * from users where 1)
from any query I attempt to send to my database.
Running php artisan migrate runs completely fine from command line showing that my settings are correct! Whats going wrong?!
.env:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=vehiclexray
DB_USERNAME=root
DB_PASSWORD=kzurxsxz1
database.php:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'database'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'password'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' =>
]
I am trying to run a website in lavarel but I keep getting the error message. I have entered the correct password and username while the error occurs that the connection was refused by the computer.
.env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=''
DB_USERNAME=''
DB_PASSWORD='' db, username and ps are filled in
config/database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
status
I just started downloading laravel 5 today. Where I install my laravel in my desktop. When I try to create a database using laravel comman php artisan migrate:install and it give's me a error SQLSTATE[HY000] [1044] Access denied for user ''#'localhost' to database 'forge' I tried a lot of examples on google but didn't work for me.
I follow on of the steps on the internet where I configure my .env file followed the array contain in database.php database to 'forge', username to 'forge' and password to ''
database.php
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
],
.env
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:oqZ6S+IZANLCbszbhef9VSPqd/4rw22oT0mixzsflZo=
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=''
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
How can I create database just typing php artisan migrate:install and automatically create laravel_migration database in my localhost? Just saw this on the internet. But when I did this it didn't create for me.
As mentioned in the comments, the tutorial assumes you are using their development virtual machine. Since you're not, you need to start up MySQL and do the following:
CREATE DATABASE IF NOT EXISTS forge;
CREATE USER forge#localhost IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON forge.* TO forge#localhost;
Once the database and user are created, you should be good to go. This should be part of their documentation...
I am new to Laravel5. I tried to create migration table but I get this error
Error Log
This is the database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'larashop'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'melody'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
and this is .env
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=larashop
DB_USERNAME=root
DB_PASSWORD=melody
Please help.
Your screenshot shows "localhost" and your code shows "127.0.0.1". MySQL treats "localhost" and "127.0.0.1" differently.
Make sure you have granted appropriate permissions for 'root'#'localhost' in your database.
http://dev.mysql.com/doc/refman/5.7/en/grant.html