currently I install laravel 8 in my Linux operating system without any error, so I started working on a simple blog-post application, and when I run php artisan migrate I get the following error.
Illuminate\Database\QueryException
SQLSTATE[HY000] [1698] Access denied for user 'hadi'#'localhost' (SQL: select * from information_schema.tables where table_schema = blog and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667▕ // If an exception occurs when attempting to run a query, we'll format the error
668▕ // message to include the bindings with SQL, which will make this exception a
669▕ // lot more helpful to the developer instead of just the database's errors.
670▕ catch (Exception $e) {
➜ 671▕ throw new QueryException(
672▕ $query, $this->prepareBindings($bindings), $e
673▕ );
674▕ }
675▕
+34 vendor frames
35 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
I search for my problem here and other sites but I can't find an exact solution.
Hope to get one
Check your file .env. Make sure its correctly.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_username
DB_PASSWORD=your_password
In case, you put correct credential but it still not work you can:
Delete Cache Files From root/boostrap/chache/files and Run The App
Related
I have a mysql service running on port 3308 using docker. However on table plus when I try to access this using “127.0.0.1” as the Host and Port “3308”, enter the user, password and database name if I test the connection it shows an error:
Lost connection to MySQL server at 'reading initial communication packet', system error: 0
Also If I run php artisan migrate I get:
Illuminate\Database\QueryException
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO) (SQL: select * from information_schema.tables where table_schema = project and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
708▕ // If an exception occurs when attempting to run a query, we'll format the error
709▕ // message to include the bindings with SQL, which will make this exception a
710▕ // lot more helpful to the developer instead of just the database's errors.
711▕ catch (Exception $e) {
➜ 712▕ throw new QueryException(
713▕ $query, $this->prepareBindings($bindings), $e
714▕ );
715▕ }
716▕ }
If I use the port 3306 on tableplus I can connect to the database but still get the issue with the php artisan command. But it's strange because in docker is configured with port 3308.
The .env file is like this:
DB_CONNECTION=mysql
DB_HOST=host.docker.internal
DB_PORT=3308
DB_DATABASE=project
DB_USERNAME=root
DB_PASSWORD=pass
Do you know what can be the issue?
Are both container, php-fpm and the database-service-container, in the same network? Did you change the database config in .env? The config parameter DB_HOST should not show an ip, instead set it to the name of your mysql container/Service. Eg.G DB_HOST=database
I was created rest API with Lumen and pgsql in my localhost then its running perfect when I test to call my API with postman, then I run php artisan migrate on server production in cloud and run success. But when I call my API in cloud it show error like this
{
"code": "500",
"message": "SQLSTATE[HY000] [2002] No such file or directory (SQL: select `id`, `payment` from `myDb` where `client_id` = xxxxx and `client_secret` = xxxxxxx limit 1)",
"data": null
}
Please someone can help me.
Thanks advance
config file
enter image description here
#my appService provider
enter image description here
can someone tell me about this problem after I input composer install that problem says and now I cant migrate
[Illuminate\Database\QueryException] Database (C:\xampp\htdocs\shop2\database\db.sqlite) does not exist. (SQL: PRAGMA foreign_keys=1)
when I run php artisan migrate this problem show
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [1049] Unknown database 'config/database.php' (SQL: select * from information_schema.tables where t
able_schema = config/database.php and table_name = migrations)
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [1049] Unknown database 'config/database.php'
[PDOException]
SQLSTATE[HY000] [1049] Unknown database 'config/database.php'
Create an empty file with name of db.sqlite in your database folder of the app. Then, run php artisan migrate, It will be filled by the app.
Hello guys I was getting errors with my Magento 2 Store.. Such as Failed API Requests, Swagger gives 500, Stylesheets and JS files won't load etc..
Finally I found that the best solution to create a fresh Magento installation with fresh theme files and just copy pub/media from files and go with maintenance mode to drop all tables prefixed with customers_ , catalog_ , sales_ and eav_
This step made my new store works very good but I got new kind of errors .. I can't run setup:upgrade it shows a message with:
[PDOException] SQLSTATE[HY000]: General error: 1823 Failed to add the foreign key constraint 'porosec_pororom/CAT_CTGR_PRD_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID' to system tables
Error when I run php -f bin/magento setup:db-schema:upgrade
The Command which occur the pervious message
also when I run composer update it updates many of dependencies but it require to run setup:upgrade.
Swagger Error 500
{"0":"Please upgrade your database: Run \"bin/magento setup:upgrade\"
from the Magento root directory.\nThe following modules are
outdated:\nKlarna_Core data: current version - 4.1.5, required version
- 4.2.3\nKlarna_Ordermanagement data: current version - 4.1.2, required version - 4.1.3","1":"#0
/home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(121):
Magento\Framework\Module\Plugin\DbStatusValidator->beforeDispatch(Object(Magento\Framework\App\FrontController\Interceptor),
Object(Magento\Framework\App\Request\Http))\n#1
/home/porosec/public_html/test/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73):
Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#2
/home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(135):
Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor),
Object(Closure), Object(Magento\Framework\App\Request\Http))\n#3
/home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(153):
Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#4
/home/porosec/public_html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26):
Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch',
Array, Array)\n#5
/home/porosec/public_html/test/vendor/magento/framework/App/Http.php(135):
Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#6
/home/porosec/public_html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24):
Magento\Framework\App\Http->launch()\n#7
/home/porosec/public_html/test/vendor/magento/framework/App/Bootstrap.php(256):
Magento\Framework\App\Http\Interceptor->launch()\n#8
/home/porosec/public_html/test/index.php(39):
Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#9
{main}","url":"/test/swagger","script_name":"/test/index.php"}
Swagger Error log
Also here's what I got in admin dashboard
Admin Panel error
[2018-06-04 23:18:09] main.CRITICAL: Report ID: webapi-5b15c8b17792e; Message: Class "array" does not exist. Please note that namespace must be specified. {"exception":"[object] (Exception(code: 0): Report ID: webapi-5b15c8b17792e; Message: Class \"array\" does not exist. Please note that namespace must be specified. at /home/porosec/public_html/test/vendor/magento/framework/Webapi/ErrorProcessor.php:205, LogicException(code: 0): Class \"array\" does not exist. Please note that namespace must be specified. at /home/porosec/public_html/test/vendor/magento/framework/Reflection/TypeProcessor.php:139)"} []
Admin Panel error log
if you have taken the backup of same table and if foreign key constraint is same as bkp table and current table mysql will throw exception, so change the constraint name or delete the existing constraint.
constraint name should not be same.
in windows command promt full eror it gives same with some php artisan commands
C:\xampp\htdocs\jj>php artisan migrate
In Connection.php line 664:
SQLSTATE[HY000] [1049] Unknown database 'juwelleryjournal' (SQL: select * from information_schema
.tables where table_schema = juwelleryjournal and table_name = migrations)
In Connector.php line 67:
SQLSTATE[HY000] [1049] Unknown database 'juwelleryjournal'
, & php artisan make:"blabla" works well
If you encounter same error, latest windows php version could be an option for you, but it helped only my classmate, not me. The i found on already being in stack overflow (Call to undefined method Illuminate\Database\Schema\MySqlBuilder::defaultStringLength()) and didn't help either. This occurs same on laptop(win7) and desktop pc(win10). I have laravel5.5.28 on both.
Have anyone any suggestions?
Add this to your AppServiceProvider
use Illuminate\Support\Facades\Schema;
function boot()
{
Schema::defaultStringLength(191);
}
Call to undefined method Illuminate\Database\Schema\MySqlBuilder::defaultStringLenght()
=> the method name is wrong, it should be defaultStringLength