Laravel 4: Oracle Connection is failing suddenly - php

I have a Laravel 4 website on my localhost and i was using Oracle database.
I tested it perfectly for weeks, no problem occured.
Suddenly when it started giving the error: ORA-01017: invalid username/password; logon denied
In my app/config/database.php i have,
'oracle' => array(
'driver' => 'pdo-via-oci8',
'host' => 'localhost',
'port' => '1521',
'database' => 'orcl', //xe Service ID
'username' => 'system', //schema
'password' => '123',
'charset' => '',
'prefix' => '',
),
My SQL PLUS and Sql Developer is running fine with the same username-password.
Please help .

Try ALTER SYSTEM SET SEC_CASE_SENSITIVE_LOGON = FALSE;

Related

How to connect SQLserver 2014 to Laravel app

How can I connect my Laravel to my SQL SERVER 2014?
TRIED METHODS
first
I tried to use sqlsvr in my .env and change my config > database.php to 'default' => env('DB_CONNECTION', 'sqlsvr').
"my..." replace my actual credentials.
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => 'myServerName',
'port' => '1433',
'database' => 'myDatabaseName',
'username' => 'myUserName',
'password' => 'myPassword',
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
But it throws an error of:
Database [sqlsrv] not configured
second
I tried some method using odbc connection find some package on GitHub but no luck, some have errors and some not supported by Laravel 5+
OTHER INFO
I'm using Larave 6.0.1 and SQL Server 2014.
Any help will do.

Laravel application trying to authenticate user using another database

I have two applications both developed in Laravel.I have logged into the first application and doing coding. But when I try to log into the second application it gives an error of the missing 'users' table(the table in the second database I am trying to log into now which is not in the first logged in an application).
Seems like the second application is trying to authenticate the user using the first database which is not correct
Can anyone assist me with this
Dear Laroja as i get you want to authenticate with another application which have separate database then you have to define two database auth and try to build the logic if connect to first application then it uses the first database and if you want to connect with another application it will connect to other database.
Please have a sapmle code for connect two databse
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'qmops_live_server',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
# Secondary database connection
'mysql2' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => env('DB_PORT', '3306'),
'database' => 'XXX',
'username' => 'XXX',
'password' => 'QXXXX',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
please use the above code in app/config/database.php hope my solution will help you Thanks.

Artisan unable to access environment variables from $_ENV

Any artisan command I enter into the command line throws this error:
$ php artisan
<?
return array(
'DB_HOSTNAME' => 'localhost',
'DB_USERNAME' => 'root',
'DB_NAME' => 'pc_booking',
'DB_PASSWORD' => 'secret',
);
PHP Warning: Invalid argument supplied for foreach() in /home/martin/code/www/pc_backend/vendor/laravel/framework/src/Illuminate/Config/EnvironmentVariables.php on line 35
{"error":{"type":"ErrorException","message":"Undefined index: DB_HOSTNAME","file":"\/home\/martin\/code\/www\/pc_backend\/app\/config\/database.php","line":57}}
This is only on my local development system, where I recently installed apache and php. On my production system on a shared host artisan commands work just fine. The prod system has it's own .env.php, but other than that the code should be identical.
Relevant files:
.env.local.php
<?
return array(
'DB_HOSTNAME' => 'localhost',
'DB_USERNAME' => 'root',
'DB_NAME' => 'pc_booking',
'DB_PASSWORD' => 'secret',
);
app/config/database.php
<?php
return array(
'fetch' => PDO::FETCH_CLASS,
'default' => 'mysql',
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => $_ENV['DB_HOSTNAME'],
'database' => $_ENV['DB_NAME'],
'username' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
),
'migrations' => 'migrations',
),
);
The $_ENV array is populated as expected on the website - the problem appears to be with artisan only.
So I finally figured out how to fix it.
It turns out that the file was not processed as a php file because I was using a short opening tag in the .env.local.php file. Using a normal opening tag solved it. I don't know why though, as short tags work fine elsewhere.

Laravel Homestead can't connect to db

I'm having trouble connecting to the database when using Laravel Homestead. I can't really understand why it doesn't work I've tried god damn everything I guess. Now i got stuck and can't try much more and I start to interact with more people. Does stackoverflow have any good answer or advice to give me? :)
This is my settings
'mysql' => array(
'driver' => 'mysql',
'host' => $_ENV['DB_HOST'],
'database' => $_ENV['DB_NAME'],
'username' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'port' => '33060'
)
I've also tried this with the same response.
'mysql' => array(
'driver' => 'mysql',
'host' => $_ENV['DB_HOST'],
'database' => $_ENV['DB_NAME'],
'username' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'port' => '3306'
)
This is my ENV variables.
{
host: "127.0.0.1",
database: "homestead",
username: "homestead",
password: "secret"
}
The return is:
PDOException
SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)
In both Migrations as the website.
It works to connect with Sequel Pro, it looks like this in Sequel Pro.
EDIT:Is it possible that there's some kinda collision between my VagrantBox's IP and the MAMP one? I've stopped every MAMP thing I've running but still the same issue, just wondering if I need to stop it somewhere else?
You shouldn't need to specify the port at all, I'd remove that line. For host, try localhost instead. Also make sure that Homestead uses the environment you have set your database to, most likely local.
MAMP can't conflict with it, unless you've at some point manually set your MAMP MySQL port to 33060, which I very much doubt.
Here's a default file which works great for me:
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'mydbname',
'username' => 'homestead',
'password' => 'secret',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
Lycka till!
What have you got when you open the PHP REPL by typing php artisan tinker at the root of your project and then print_r(Config::get('database.connections')['mysql']); ?
You should have this:
Array
(
[driver] => mysql
[host] => localhost
[database] => homestead
[username] => homestead
[password] => secret
[charset] => utf8
[collation] => utf8_unicode_ci
[prefix] =>
[port] => 33060
)
If you have something different your environment variables are not good or you are not detecting the local environment.

Laravel - User 'root' already has more than 'max_user_connections' active connections

I have recently started using Laravel and absolutely love it, however I keep coming across the error:
SQLSTATE[42000] [1203] User 'root' already has more than 'max_user_connections' active connections
I know there is a way to change the MySQL variable to allow more connections, however this isn't an option with my host and along with this, there is no way I should of hit this limit.
Some example queries are:
return User::where('users.username', '=', Auth::user()->username)->join('settings', 'settings.username', '=', 'users.username')->first();
return Char::orderBy('calculate', 'ASC')->groupBy('charid')->get();
So my question is, what should I be looking for in order to combat the error? Should I be disconnecting myself from the database at the end of each function? Or something completely different?
Any help would be appreciated in this matter.
No, Once Change the username root to following username like *system a*nd try it
What version of Laravel do you have?
Go to "application/config.database.php" or "app/config/database.php". From here you can add custom options to your laravel database settings.
The "database.php" contains at the end something like this:
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'db_name',
'username' => 'db_username',
'password' => 'username_password',
'charset' => 'utf8',
'prefix' => '',
),
),
You can add "options" to that array, just like this:
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'db_name',
'username' => 'db_username',
'password' => 'username_password',
'charset' => 'utf8',
'prefix' => '',
'options' => array(
//here you will add your custom options
),
),
),

Categories