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.
Related
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
I'm trying to connect Laravel with a multiple sqlserver databases, I defined the connections on my database.php file correctly :
'connections' => [
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '16000'),
'database' => env('DB_DATABASE', 'dbname'),
'username' => env('DB_USERNAME', 'me'),
'password' => env('DB_PASSWORD', 'me'),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
'sqlsrv2' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '16000'),
'database' => env('DB_DATABASE_2', 'dbname2'),
'username' => env('DB_USERNAME', 'me'),
'password' => env('DB_PASSWORD', 'me'),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
],
and set my .env file
DB_CONNECTION=sqlsrv
DB_HOST=127.0.0.1
DB_PORT=16000
DB_DATABASE=dbname
DB_USERNAME=me
DB_PASSWORD=me
I try to verify the connectivity to my sql server database from another application and it's working perfectly. then I created a model on my laravel application and once I type php artisan migrate I get this error :
anyone can help to resolve this problem ?
UPDATE !
After adding pdo sqlsrv extensions to my ext folder and my php.ini i get this error :
[![enter image description here][2]][2]
[![enter image description here][3]][3]
UPDATE 3 :
After installing odbc 13 i got this problem
Ah, WAMPServer has 2 seperate php.ini files.
One is used by PHP under Apache and the other by the PHP CLI.
I see you are using the CLI, so you need to check that you have included the SQL Server drivers extension in the CLI php.ini file.
You will find that in:
C:\wamp64\bin\php\php{version}\php.ini
You have to edit this manually, there is no menu link to do this, the menu link to edit the php.ini only edits the PHP under Apache version of php.ini
Make sure you edit the php.ini file in the folder that matches the version of PHP you are actually using for this project, as of course you can have multiple versions of PHP installed under WAMPServer
UPDATE: Second Problem
You have added the 32bit AND 64 bit SQL Server drivers to your ext folder!
Your WAMPServer menu shows
1. php_sqlsrv_72_ts_x64
2. php_sqlsrv_72_ts_x32
3. php_pdo_sqlsrv_72_ts_x64
4. php__pdo_sqlsrv_72_ts_x32
as you are using 64 bit wamp, you should only have these 2
1. php_sqlsrv_72_ts_x64
2. php_pdo_sqlsrv_72_ts_x64
I'm using Laravel 5.5, php 7.1.9, and oracle 10g
i don't know if i'm connected to the database or not and if yes, is the problem in my code ?
PDOException SQLSTATE[HY000]: pdo_oci_handle_factory: Error while
trying to retrieve text for error ORA-01804
(ext\pdo_oci\oci_driver.c:640)
oracledb.php
return [
'oracle' => [
'driver' => 'pdo',
'tns' => env('DB_TNS', 'XE'),
'host' => env('DB_HOST', 'GREEN-PC'),
'port' => env('DB_PORT', '1521'),
'database' => env('DB_DATABASE', 'XE'),
'username' => env('DB_USERNAME', 'esprit'),
'password' => env('DB_PASSWORD', 'esprit'),
'charset' => '',
'prefix' => '',
'quoting' => false,
],
];
in my controller
public function show()
{
$res = DB::table('esp_etudiant')
->where('id_et','1630242')
->get();
print_r($res);
}
First, try connecting as SYSDBA.
$ sqlplus / as sysdba
There are several causes for the ORA-01804 error:
Check to make sure the following paths are set correctly in your environment:
$LD_LIBRARY_PATH
$ORACLE_HOME
$NLS_LANG
Your oracle client may be missing some timezone dat files in the $ORACLE_HOME directory. You should have a separate ORACLE_HOME for each release of Oracle. If this is the case, then :
The first thing to do is to check if ORA_TZFILE is set and if it is,
remove it and restart the database and listener. Oracle will then try
to load the $ORACLE_HOME/oracore/zoneinfo/timezlrg.dat file.
If for some reason the file that Oracle wants to use is not available
then this is the cause of the problem.
If the file is present then an alternative reason for the error could
be that Oracle cannot load the file because of permission problems.
If all above is correct then it might be a .dat file that is corrupt.
Check that the permissions are set to allow reads (chmod 444) for the files in the OCCI library.
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.
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'