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',
);
Related
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.
In my local environment I have working a secondary remote mysql connection specified in config/database.php without any problems:
# Secondary database connection
'mysql_remote' => [
'driver' => 'mysql',
'host' => env('DB_HOST_2', 'cherokee.websitewelcome.com'),
'port' => env('DB_PORT_2', '3306'),
'database' => env('DB_DATABASE_2', 'dbname'),
'username' => env('DB_USERNAME_2', 'dbusr'),
'password' => env('DB_PASSWORD_2', 'dbpass'),
'unix_socket' => env('DB_SOCKET_2', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
But when I run this on production server with the exact same database file I get the following error, is like the remote host (cherokee.websitewelcome.com) is not used and replace it with local server host (eu01.server.plus)
SQLSTATE[HY000] [1045] Access denied for user 'dbusr'#'eu01.server.plus' (using password: YES) (SQL: select ...)
Any ideas?
Solved by adding eu01.server.plus to authorized hosts on remote mysql server. Initially I was adding the IP and not hostname.
I am trying to connect remote database from my localhost, the cause of I want to store data localhost to remote server. Now I want to show simply users table info it get form my localhost and different variable show remote server users table info . I write the code example here :
In my Config/database.php:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'realstate'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'shahin' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '104.219.248.3'),
'database' => env('DB_DATABASE', 'laraveldb'),
'username' => env('DB_USERNAME', 'laraveldb_username'),
'password' => env('DB_PASSWORD', 'secret'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
In Route.php :
Route::get('mpdb',function(){
$userArray = DB::table('users')->get();
echo "<pre>";
print_r($userArray);
echo "</pre><br>";
$users2 = DB::connection('shahin');
$u = $users2->table('users')->get();
echo "<pre>";
print_r($u);
});
Local Database work's properly but Remote database get error!!
ERROR : SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
To allow external web servers to access your MySQL databases, add their domain names to the list of hosts that are able to access databases on your web site.
see a hosted cpanel demo(Image)
If you want to all incoming hosts you may access like this %.%.%.%
You can see this picture
How to permit other incoming host(Image)
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 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',
);