I can't connect to a mssql database server using theese settings.
I get this error:
Fatal error: Call to undefined method DboSource::connect() in /home/websites/CakeShare/cake/libs/model/datasources/dbo_source.php on line 143
do i have to do something with my server?
$this->db_data['test'] = array(
'driver' => 'mssql',
'persistent' => false,
'host' => 'test.test.com',
'login' => 'login',
'password' => 'pass',
'database' => 'testdb',
'prefix' => ''
);
in /app/config/core.php
you can set the debug level from 0 to 2, please change the error level to 2 and give the ouptut.
Related
I have been trying to solve this issue already for a few days without any results. When using default php pdo object I can connect to the database:
$db = new \PDO('mysql:unix_socket=/cloudsql/project-id:database-instance;dbname=test',
'root', // username
'' // password
);
But when trying to connect with ZF2 adapter the connection just times out.
'db' => array(
'driver' => 'Pdo_Mysql',
'database' => 'test',
'username' => 'root',
'unix_socket' => '/cloudsql/project-id:database-instance',
),
I am quite sure that the problem is somehow with the unix_socket as I can connect to the Cloud SQL server from my localhost directly without socket:
'db' => array(
'driver' => 'Pdo_Mysql',
'host' => 'xxx.xxx.xxx.xxx',
'database' => 'test',
'username' => 'user',
'password' => 'password',
),
What I am missing?
unix_socket isn't a recognized option for the pdo driver (https://github.com/zendframework/zf2/blob/master/library/Zend/Db/Adapter/Driver/Pdo/Connection.php#L164). Try this instead
'db' => array(
'dsn' => 'mysql:unix_socket=/cloudsql/project-id:database-instance;dbname=test',
'username' => 'user',
'password' => 'password',
)
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.
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;
This has me stumped. I am trying to set encoding for my Sqlserver connection and all that I have tried has failed. I only get
Error: A Database connection using "Sqlserver" was missing or unable
to connect. The database server returned this error:
SQLSTATE[IMSSP]: An invalid encoding was specified for
SQLSRV_ATTR_ENCODING.
The original error I was trying to solve through encoding is:
Error: SQLSTATE[IMSSP]: An error occurred translating the query string
to UTF-16: No mapping for the Unicode character exists in the target
multi-byte code page.
The SQL version is 2008 R2
Cakephp Version: 2.4.2
PHP Version: 5.3.27
After a lot of trial and error this works:
public $default = array(
'datasource' => 'Database/Sqlserver',
'persistent' => false,
'host' => 'localhost',
'login' => 'sa',
'password' => 'password',
'database' => 'SchedulingDatabase',
'encoding' => PDO::SQLSRV_ENCODING_UTF8
);
Tried this out with Cakephp 3.0 seems to work nicely.
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Sqlserver',
'persistent' => false,
'host' => 'localhost',
'port' => '1433', //using this port
'username' => 'sa',
'password' => 'password',
'database' => 'cake_bookmarks',
'encoding' => PDO::SQLSRV_ENCODING_UTF8,
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
]
SQL 2008 doesn't support UTF-16 only SQL 2012
http://msdn.microsoft.com/en-us/library/ms143726(v=sql.110).aspx
UTF-8 isn't supported at all by MS SQL.
I am getting this error when I am accessing ORM in a script run from the command line:
Database_Exception [ 2 ]: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) ~ MODPATH/database/classes/kohana/database/mysql.php [ 67 ]
This is my directory structure
application
--bootstrap.php
modules
content
--index.php
system
This is my database config:
$database_config = array
(
'default' => array
(
'type' => 'mysql',
'connection' => array(
'hostname' => 'localhost',
'database' => 'driverslife',
'username' => 'root',
'password' => 'root',
'persistent' => FALSE,
'port' => 8889
),
'table_prefix' => '',
'charset' => 'utf8',
'caching' => FALSE,
'profiling' => TRUE,
),
);
When I echo MODPATH in the command line, it shows me the right path(slash appended). Is there anything I might be missing?
Use 127.0.0.1 instead of localhost in your config. More info here:
Error when connecting to MySQL using PHP/PDO