I am beginner of using laravel 6, so this the error message that I faced,
1) SQLSTATE[42S02]: Base table or view not found: 1146 Table
'forge.settings' doesn't exist (SQL: select * from settings where
auto_load_disabled is null)
2)SQLSTATE[42S02]: Base table or view not found: 1146 Table
'forge.settings' doesn't exist
even I have tried the command php artisan migrate:fresh but it exists the same error, the command include
php artisan serve, php artisan migrate, are also not work for me..
Below are the code,
In my .env file:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=root
DB_PASSWORD=
The command php artisan migrate:key is not work, the error message is same to the above 1) and 2)...
and I have also try to copy another app key that can run on the server but still not work.
The database I have already create on phpmyadmin named 'forge' using xampp server.
my 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,
'modes' => [
'STRICT_TRANS_TABLES',
'NO_ZERO_IN_DATE',
'NO_ZERO_DATE',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_AUTO_CREATE_USER',
'NO_ENGINE_SUBSTITUTION'
],
'engine' => 'InnoDB',
]
Can anyone help me? Please..
Related
I have an aplication that works with angularjs and its backend is on Laravel. I'm working on Fedora 37.
The back is in a docker container, and I have a local database with mysql.
When I try to query anithing to the database, it brings the next error:
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from
usuarios where email = admin#test and usuarios.deleted_at is
null limit 1)
The .env file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=wymaq
DB_USERNAME=root
DB_PASSWORD=
Frontend is located in localhost:9001, and its linked in config.app.js to back (localhost:8080) like this:
.constant('API_CONFIG', {
'url': 'http://127.0.0.1:8080/', etc...
My database.php file is configured like this:
'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', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'unix_socket' => '/var/lib/mysql/mysql.sock',
'strict' => true,
'engine' => null,
'modes' => [
'ONLY_FULL_GROUP_BY',
'STRICT_TRANS_TABLES',
'NO_ZERO_IN_DATE',
'NO_ZERO_DATE',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_ENGINE_SUBSTITUTION',
],
],
In windows, there is no problem. I have the database in another container and it works. I tried it here in fedora but its the same error.
I get my mysql socket and its: '/var/lib/mysql/mysql.sock'
When i type php -i | grep pdo in the back container i get this:
pdo_mysql.default_socket => no value => no value
Anytime I do local dev w/ docker, and a SQL database (running on the host), the host name for the database that works for me is: host.docker.internal
So first thing first i've created migration tables and it successfully migrated and seeded. i've change the .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=jj
DB_USERNAME=root
DB_PASSWORD=
i've tried to change the database.php
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'jj'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'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'),
]) : [],
],
but i'm still unable to login. the error says SQLSTATE[HY000] [1049] Unknown database 'laravel' (SQL: select * from `users` where `username` = admin limit 1) even though i've migrated and seeded the database
If the configuration looks okay and you are 100% certain that MySQL is running, you might want to clear the configs and caches.
php artisan config:clear
php artisan cache:clear
Try the config one and then the cache if the problem isn't resolved by the first command.
You can read more about the commands here
I'm aware this can be a recurring question, but none of the solutions i found online seem to be working with my problem.
I have a Laravel 5.8 project but i can't access to my database from a controller, all artisan command works fine (like php artisan migrate)
But when a try a simple thing like:
protected function test()
{
return User::all();
}
I get SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `users` where `users`.`deleted_at` is null)
I simply trying to access my local database (from OSX)
My Config :
.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=root
DB_PASSWORD=secret
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', 'database'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
],
My database is working (i can access it with an IDE or else)
Thanks for your help !
it isn't the best answer, but create new database user with all privileges and use that user.
I am new to Laravel. I am trying to create a laravel CRUD with resource controllers. However, when I try to run php artisan migrate I get the following error:
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from
information_schema.tables where table_schema = homestead and
table_name = migrations)
Here is my database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'design'),
'username' => env('DB_USERNAME', 'homestead'),
'password' => env('DB_PASSWORD', 'secret'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
and this is my env file:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:hLJn+XHKPjf5qEvROeyMMLIjw56Kg9RkXhZIlbjjne4=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=design
DB_USERNAME=homestead
DB_PASSWORD=secret
This is a common problem and I have tried many solutions but they wont work. Please help.
try to use PORT 3306 and change localhost to 127.0.0.1
for example
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
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...