Laravel setup of migrations using Artisan is failing - php

I am trying to set up migrations for the first time and when I run
php artisan migrate:install
from within the root folder of my project I get the following SQLSTATE error:
SQLSTATE[HY000] [2002] No such file or directory
I have tested running mysql to make sure it is working and referenced and I have ran php artisan help:commands to make sure artisan is working (it is).
The website itself is functioning and reading from the database fine.

This may be an issue with the sockets if you're using MAMP or XAMPP.
From http://forums.laravel.io/viewtopic.php?id=980...
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
'database' => 'database',
'username' => 'user',
'password' => 'pass',
'charset' => 'utf8',
'prefix' => '',
),
),
You can pass an optional "unix_socket" to the array and specify the MAMP socket instead of the default location.

Also, try and change 'host' => 'localhost', to 'host'=> '127.0.0.1', because unix does not recognise 'localhost'

Related

Django postgres database not connecting with Lumen

I am trying to connect django.db.backends.postgresql with my lumen application. But when I run the query then following error occured
could not find driver
Even I change the driver type from mysql to pgsql
My database connection
'ml_db' => [
'driver' => 'django.db.backends.postgresql',
'host' => env('ML_DB_HOST'),
'port' => env('ML_DB_PORT'),
'database' => env('ML_DB_NAME'),
'username' => env('ML_DB_USER'),
'password' => env('ML_DB_PASS'),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_general_ci'),
'prefix' => '',
'timezone' => env('DB_TIMEZONE', '+00:00'),
'strict' => false,
],
Is there any way to connect this database with my lumen application because I am using multiple databases in application.
The obvious answer here is, that you haven't installed the corresponding driver for your used dbms. So just install it.
from your configuration posted in the question, I assume that it's your lumen configuration. There is no 'django.db.backends.postgresql' driver in lumen. What we have is pgsql driver unless you create such a custom driver yourself,(which I assume is not the case).
so change the driver parameter to the following?
'driver' => 'pgsql',
Lumen .env file:
DB_CONNECTION=pgsql
DB_HOST=your host
DB_PORT=5432
DB_DATABASE=database
DB_USERNAME=username
DB_PASSWORD=password
The link

Oci8Exception in Oci8.php line 466

Attempting to connect to an Oracle database with yajra/laravel-oci8, below is the configuration. Note that I've also installed the instant client 11g corresponding to the bit version of Windows Server. I've ensured that the 11g ext is enabled in the php.ini.
Spent 4 days on this now, does anybody have any idea what's going on?
I don't even get an error message, just a stack dump which is attached.
'oracle' => [
'driver' => 'oracle',
'tns' => 'LISTENER',
'host' => '192.168.39.73',
'port' => env('DB_PORT', '1521'),
'database' => 'QORA',
'username' => 'ETEST',
'password' => 'ETEST',
'charset' => env('DB_CHARSET', 'AL32UTF8'),
'prefix' => env('DB_PREFIX', ''),
'prefix_schema' => env('DB_SCHEMA_PREFIX', ''),
],
Your error messages are showing you are trying to connect on port 3306, which is the standard MySQL port. According to your config, you're looking at the DB_PORT value from the .env file, with a backup of 1521 if that doesn't exist.
My guess is that your .env file has the following line:
DB_PORT=3306
You either need to comment or remove that line, or change 3306 to 1521.

PHP SQLSTATE[HY000] [1045] Access denied for user Laravel

I'm working on a project (PHP Laravel 4.2) using SVN with team, After I checked out the repository on my disk (local), and tried to open the link localhost/mylaravel, I got this error
PDOException (1045) SQLSTATE[HY000] [1045] Access denied for user
'dbusername'#'xx.xxx.xx.xxx' (using password: YES)
Note: I changed the real username and host IP
the database not locally, It's remotely hosted online. but the project is on localhost.
config/database.php
'connections' => array(
'sqlite' => array(
'driver' => 'sqlite',
'database' => __DIR__.'/../database/production.sqlite',
'prefix' => '',
),
/**
* remote database connection
*/
'mysql' => array(
'driver' => 'mysql',
'host' => 'hostIP:port',
'database' => 'mydatabasename',
'username' => 'mydbusername',
'password' => 'root123456',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'pgsql' => array(
'driver' => 'pgsql',
'host' => 'localhost',
'database' => 'forge',
'username' => 'forge',
'password' => '',
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
),
'sqlsrv' => array(
'driver' => 'sqlsrv',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'prefix' => '',
),
)
Just run the following artisan commands in your terminal.
1. php artisan cache:clear
2. php artisan config:cache
Refresh your url now and the login will works perfectly.
$ php artisan cache:clear
Application cache cleared!
$ php artisan config:cache
Configuration cache cleared!
Configuration cached successfully!
Run php artisan cache:clear then php artisan config:cache on your terminal in the respective path.
The above should be the results
I Faced Same Problem i did
php artisan cache:clear
php artisan config:cache
but Same problem found than i run this artisan command
php artisan view:clear
Hope it will helpful.
Note: my project was Laravel 5.*
Just only change .env file and DON'T change config/database.php file. Please make config/database.php file as default.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1 or IP address
DB_PORT=3306
DB_DATABASE='your database name'
DB_USERNAME='your username'
DB_PASSWORD='your password'
it works for me!
Please run the command line:
php artisan optimize

Laravel PHPUnit PDOException exception

I don't know why when I run a PHPUnit test, I get the following error:
PDOException: SQLSTATE[HY000] [2002] No such file or directory
My testing environment database setting is:
return [
'fetch' => PDO::FETCH_CLASS,
'default' => 'mysql',
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'clg_test',
'username' => 'root',
'password' => 'veryHardPass',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]
],
'migrations' => 'migrations',
];
The reason why I am using MySQL as oppose to SQLite is because my migration files use dropColumn which is not supported by SQLite. I call the migration via Artisan::call('migrate') in the setup.
If I actually call migration manually in the terminal via php artisan migrate --env=testing then the migration IS successful and the databases are created.
Why am I then facing the above problem?
Try changing localhost to 127.0.0.1. The message you're getting is indicative of the script not being able to connect to MySQL through a socket, but using an ip should work.

Laravel Artisan Migrate connection refused

My website works, its clearly accessing the database. I can log in and i can create records, etc...
Ive created a new migration, and I'm trying to insert it, but when i run
php artisan migrate
i get the error
[PDOException]
SQLSTATE[HY000] [2002] Connection Refused
My database config has the passwords hidden in the environment so my config looks like this
'mysql' => array(
'driver' => 'mysql',
'host' => getenv('DB_HOSTNAME'),
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USERNAME'),
'password' => getenv('DB_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
my environment variables are loading correctly. What am i missing?
I figured it out. Apparently the environment that artisan was seeing was different from the environment i wanted it to see, so it was using the wrong host
php artisan migrate --env=production

Categories