I have my Cake app and it's is working on my PC on Apache but it connects to the remote database.
And everything is fine.
But when I copied my app on server, there is an error when I try to execute any controller:
Error: SQLSTATE[HY000] [2005] Unknown MySQL server host 'xx.xx.xx.xx:33306' (2) requires a database connection
Error: Confirm you have created the file : app/Config/database.php.
And I tested the connection in simple php script (on server) and I connect and get data from this database without problem. So why Cake can't connect to it?? What might be problem?
public $external = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'xx.xx.xx.xx:33306',
'login' => 'xxx',
'password' => 'xxx',
'database' => 'xxx',
);
The file 'database.php' exists in app/config and has permissions rwxr-xr-x
I am not sure about mod_rewrite... how I can check it?
'host' => 'xx.xx.xx.xx:33306',
is not allowed. You should use the optional port option as specified in the CakePHP docs.
public $external = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'xx.xx.xx.xx',
'port' => '33306',
'login' => 'xxx',
'password' => 'xxx',
'database' => 'xxx',
);
Related
I installed virtualmin on a VM instance using google compute engine. I have set up 1 domain and 1 subdomain. On the subdomain i created a database (flexijobs) and added the Drupal tables. Everything works fine except the connection to the database. On loading the drupal index page i get this error:
PDOException: SQLSTATE[HY000] [2002] Connection timed out
My guess is that the settings are not correct, so in a virtualmin setup, what should i use here, where can i set the password/user, what port should i use, what is the host?
$databases['default']['default'] = array (
'database' => 'flexijobs',
'username' => 'someUsername',
'password' => 'somePassword',
'prefix' => '',
'host' => 'db.somedomain.com',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
Create a new database through Webmin > Servers > MariaDB Database Server
Note the name, username and password for the database you just made and modify the configuration file to include the information for your database.
The host field should be set to localhost
$databases['default']['default'] = array (
'database' => 'database_name',
'username' => 'db_username',
'password' => 'db_password',
'prefix' => '',
'host' => 'localhost',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
I want to connect to CakePHP3.77 with MySQL 5.7.25 in MAMP.
I cannot connect with database named cake_youtube_db.
Error Message is this.
CakePHP is NOT able to connect to the database.
Connection to database could not be established: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
I did try create other users and put user and password.
However they did not work.
/config/app.php
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
//'port' => 'non_standard_port_number',
'username' => 'root',
'password' => 'root',
'database' => 'cake_youtube_db',
SQL plugin is mysql_native_password.
I expect Database will be connected with my cakeapp.
Hi after changing to Schema type of database and the CakePHP version from 2.4.4 to 2.9.7 the test database just doesn't want to work: Error: Database connection "Mysql" is missing, or could not be created. when I want to run tests: ./Console/cake test app AllModel.
Here is my database.php file:
<?php class DATABASE_CONFIG {
public function __construct() {
$this->default = array(
'datasource' => 'Database/Mysql',
'driver' => 'mysql',
'persistent' => false,
'encoding' => 'utf8',
'prefix' => 'prefix_',
'host' => 'localhost',
'database' => 'db',
'login' => 'root', /*** replace this ***/
'password' => 'pass', /*** replace this ***/
);
$this->test = $this->default;
$this->test['database'] = $this->test['database'].'_test';
}
Here you can see, that the test database is just a copy of default one. But the default database is working and is connected, while the test database is giving me an error. What could it be ?
All I needed to do is to just create a database with a name db_test, but not populate it, because later it would be populated with fixtures.
When I try to login to the app I have setup on Forge, my Laravel app spits out this error:
SQLSTATE[HY000] [1045] Access denied for user 'appname'#'localhost' (using password: YES)
I have the environment variables configured correctly and they work fine on my copy of the site on my local Homestead vagrant box.
Here is the .env.php file that Forge wrote:
return [
'APP_ENV' => 'production',
'DB_DRIVER' => 'mysql',
'DB_HOST' => 'localhost',
'DB_NAME' => 'appname',
'DB_USER' => 'appname',
'DB_PASS' => 'LoNgPaSsWoRd',
];
Here is the relevant contents of app/config/database.php which works locally:
'default' => getenv('DB_DRIVER'),
'connections' => array(
'mysql' => array(
'driver' => getenv('DB_DRIVER'),
'host' => getenv('DB_HOST'),
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USER'),
'password' => getenv('DB_PASS'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
),
I tried dumping the environment values before the first database connection is accessed using dd(getenv('DB_PASS'), getenv('DB_USER')) and they show up correct.
I also tried connecting through MySQL Workbench and resetting the password to exactly what is shown in the environment variable Forge wrote.
None of my other subdomains are having this issue.
What could be going on here and how could I debug this?
I deployed my app on a remote host and everything works as expected. But when I try to test my code on localhost, it gives me the following error, without any change to the code working on the host:
Fatal error: Class 'AppHelper' not found in [path]
I am using CakePHP 2.1 and MySQL as my default datasource.
I connect to my local database just like to the remote one (with authentication changes):
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'database',
'prefix' => '',
'encoding' => 'utf8',
);
Why isn't this working on my localhost? Thank you
Two possible things:
either you didnt know about the AppHelper requirement for 2.1:
http://book.cakephp.org/2.0/en/appendices/2-1-migration-guide.html
or you forget to declare the helper at the very top of your class:
App::uses('AppHelper', 'View/Helper');
Although the second one is highly unlikely if you are not running any unit tests.
So my bet is on the first one.