Closed mianshargeel closed 7 years ago
Are you on Mac or Linux?
I m on mac
Could you update this issue with your mysql version?
If this is a fresh install, do you see the migrations table in the DB (i.e. what happens when you execute the query from the exception directly in mysql)? I had once a similar issue and it was caused by the wrong configuration of DB connection parameters (in my case it was hostname).
Sisve I have already updated mysql
You may have to specify a connection socket in your config or use 127.0.0.1
as your DB_HOST
rather than localhost
It seems a database schema issue. Can you test without schema or whatever? By the way, does MySQL have schema like PostgreSQL?
this is my config/database.php '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' => '', 'strict' => true, 'engine' => null, ],
and this is my .env file
DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=laravel_5 DB_USERNAME=root DB_PASSWORD=root
For me, is a bug on artisan in all Laravel versions. I have a similar issue on Laravel 4.2 using server variables for database connection. If I configure on database.php each value with direct values, artisan works, but if I use environment or server variables, artisan displays the mentioned error.
i also tried to submit all connection data(DB_name, username, pass etc) in my database.php but i did't works
As far as I know you can not have both .env file and environment settings done via shell.
'host' => '127.0.0.1:3306', //or localhost
'database' => 'forge',
'username' => 'forge',
'password' => '',
Without unix_socket. In my case works for migrations and commands. Just I tried to log a server custom variable on command and it goes empty, so for .env files on >=L5 or using directly server variables I think we will need to do something like this StackOverflow question
Looks like a configuration issue, the query you shared is for postgres grammar not MySQL, please double check your config because a fresh laravel installation works with no issues.
Closing but feel free to continue discussion.
again getting thie kind of error
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [1049] Unknown database 'blog' (SQL: select * from information_schem
a.tables where table_schema = blog and table_name = migrations)
[PDOException]
SQLSTATE[HY000] [1049] Unknown database 'blog'
Your database 'blog' does not exist.
NowNewStart but I created database 'blog' myself in mysql it is existing but when I run php artisan migrate I m getting that error, actually I m very junior in Laravel maybe I m missing something ... ?
I have similar issue, php artisan migrate thinks that databasse name is information_schema even i specified database name in .env and it tries to use sqlite even i have mysql specified.
No one is answering this? Having the same problem.
@mianshargeel @bujashaka Have you already solved it?
@kennblvnp This error is pretty generic, there's a chance your issue is completely different.
There is something weird that I noticed.
@kevdotbadger my localhost link is this: http://localhost:8888/phpmyadmin/index.php
but displayed in website phpmyadmin is: Server: localhost:8889
What does that mean?
This is my .env file by the way
> APP_NAME=Laravel
> APP_ENV=local
> APP_KEY=base64:cmB21VLopjlYMSrCrmuWlKYx22cUDUm5jbXXYBu71ks=
> APP_DEBUG=true
> APP_LOG_LEVEL=debug
> APP_URL=
>
> DB_CONNECTION=mysql
> DB_HOST=localhost
> DB_PORT=3306
> DB_DATABASE=ppp
> DB_USERNAME=root
> DB_PASSWORD=root
>
> BROADCAST_DRIVER=log
> CACHE_DRIVER=file
> SESSION_DRIVER=file
> SESSION_LIFETIME=120
> QUEUE_DRIVER=database
>
> REDIS_HOST=127.0.0.1
> REDIS_PASSWORD=null
> REDIS_PORT=6379
>
> MAIL_DRIVER=smtp
> MAIL_HOST=smtp.mailtrap.io
> MAIL_PORT=2525
> MAIL_USERNAME=null
> MAIL_PASSWORD=null
> MAIL_ENCRYPTION=null
>
> PUSHER_APP_ID=
> PUSHER_APP_KEY=
> PUSHER_APP_SECRET=
>
What is port on 8888 and then shows up 8889? @kevdotbadger
Hi sorry I didn't solve it.
On 5 Jan 2018 5:25 pm, "Kenn Blvnp" notifications@github.com wrote:
What is port on 8888 and then shows up 8889? @kevdotbadger https://github.com/kevdotbadger
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/laravel/framework/issues/19522#issuecomment-355581227, or mute the thread https://github.com/notifications/unsubscribe-auth/ATgi1NQGRFayWlgJQTNnSjkS4jTNo7KPks5tHj7fgaJpZM4NzS_M .
@mianshargeel @kevdotbadger It was already answered a few scroll up.
Solution: https://stackoverflow.com/questions/27365473/mamp-with-laravel-unix-socket
Quick solution: DB_HOST=localhost;unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock (at .env file)
By @rossjcooper answer
Thanks!
I think for .env file on Laravel should be needed https://github.com/vlucas/phpdotenv on artisan migrations.
Try changing DB_HOST
in your .env to 127.0.0.1
i too have same issue while installing crudbooster.
In Connection.php line 664:
SQLSTATE[HY000] [1049] Unknown database 'project1' (SQL: select * from information_schema.tables w here table_schema = project1 and table_name = migrations)
In PDOConnection.php line 47:
SQLSTATE[HY000] [1049] Unknown database 'project1'
In PDOConnection.php line 43:
SQLSTATE[HY000] [1049] Unknown database 'project1'
but migrations file are created in databse
@devamit2018 u need to first create a database called project1 in phpmyadmin
generally i create laravel from laragon and install crudbooster.it was working fine since crudbooster would automatically create database after changing in env file..
I think @devamit2018 you should report this issue to: https://github.com/crocodic-studio/crudbooster
Can anyone resolved this problem? I have same it :(( Help meeeeee
have you read all the conversation? there are solutions you can try if you read it. @huykon
@mianshargeel I had the exact problem. I needed mysql driver. So just install php-mysql
@kennblvnp I have read all and changing DB_HOST in your .env to 127.0.0.1 but this is not resolve. Can you help me?
Try using get_cfg_val
Hey @huykon have you already tried this?
DB_HOST=localhost;unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock
I solved the same issue by verifying in /config/database.php the lines 50/51 'charset' => 'utf8', 'collation' => 'utf8_general_ci', Make sure the values correspond to your Database settings.
Just dont't use sleeping owl base ".env" file, use laravel ".env". Here is example of correct data: APP_NAME=Laravel APP_ENV=local APP_KEY=base64:Bzu2Qk1vQ2WahfXJeuPSV95dpEGNmmjJ30aB9ZNmdHA= APP_DEBUG=true APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laraveladmin DB_USERNAME=root DB_PASSWORD=
BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file SESSION_LIFETIME=120 QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379
MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=rotaralek@gmail.com MAIL_PASSWORD=newrotar MAIL_ENCRYPTION=tls
PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
@rotaralek You might want to edit your post and remove your gmail credentials.
Using 127.0.0.1 worked for me. I was a little surprised as to why, as it worked under localhost until recently. I traced it back to me enabling the Firewall on my Mac.
php artisan config:cache solved it for me - nothing else had helped
I had this issue too on fresh Laravel 5.6,
lluminate\Database\QueryException : SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = projectLDM and table_name = migrations)
Same Problem.
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table
_schema = test and table_name = migrations)
hi @beidilu, i've solved this problem, don't use PHP 7.2.5, after i downgrade PHP version to 7.1.17, the error does not show up. i don't know why
Thanks, ganyuciha. That's good to know. I just switched to Windows :(
Using the 127.0.0.1 instead of "localhost" for DB_HOST should fix in most cases. Not sure why this is, but this has been an issue for some time.
Use:
DB_HOST=127.0.0.1
In .env in project
DB_PORT=3306
to
DB_PORT=33060
also for the PHP requests to work do
DB_HOST=localhost
Fixed for me 🤷.
Windows.
uncomment extension=php_pdo_mysql.dll in php.ini
This solution worked for me:
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';
I am on Mac and my info is:
Laravel: 5.6.28
PHP: 7.2.7
mysql: 8.0.11
DB_HOST=localhost
DB_PORT=3306
Notes: database created and I didn't uncomment extension=php_pdo_mysql.dll in php.ini
For Laravel Framework 5.6.33 ,
use \Illuminate\Database\Schema\Builder::defaultStringLength(191);
Description:
i m running command: php artisan migrate and getting such like Exception as [Illuminate\Database\QueryException]
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables
where table_schema = laravel3 and table_name = migrations)
Steps To Reproduce: