Google-App-Engine[PHP]: Error trying to establish database connection - php

I am finding a problem with the cloudsql as database connection is not being established. I have followed the following site step-by-step https://googlecloudplatform.github.io/appengine-php-wordpress-starter-project/
However I seem to be finding problems after deploying the project to the appengine and accessing the wordpress installation page with URL: https://<PROJECT-ID>.appspot.com/wp-admin/install.php
The error shown is:
**Error establishing a database connection**
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress_db' );
/** MySQL database username */
define( 'DB_USER', 'root' );
/** MySQL database password */
define( 'DB_PASSWORD', '' );
Can someone please advise a suitable solution to this error, as I cannot get around it and even though I am able to deploy my project. Without a database connection I cannot install Wordpress on cloudsql accordingly.

I have solved this problem with a work around. Since I was following the instructions from the web page, I researched further on the contributors behind it, leading to the GitHub link:
https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/appengine/wordpress
This was updated as of 2015, and I was able to follow the step-by-step procedure from this URL. I found it necessary to install the GitHub shell commands and clone the project to desktop.
All I needed to do was update the app.yaml and wp-config.php as required and than create the instance on Cloud SQL, following the 'wordpress' procedure with a new database created as wordpress_db and a new root user with a blank password.

Related

lightsail unable to find database

i am new at AWS lightsail, basically just following the instruction step by step create a instance, create a database named mypost, and upload all file to instance by filezilla, and then use potty to connect phpmyadmin, export local database into online database, but somehow when i test the link on browser it tell me Connection Error: SQLSTATE[HY000] [1049] Unknown database 'mypost' , i checked both phpmyadmin and database in the aws console all named mypost, i also switched to public mode as well, anyone know why is it?

Wordpress still trying to connect to old database

I am Running wordpress on Ubuntu 18.04 with apache2 and PHP 7.2.24. I deleted the wordpress files and dropped the database to copy another wordpress site. I copied the other wordpress (Files and database) into a new database (new name, new user, new password), Then changed the wp-config.php file values to the (new name, new user, new password). Now when I try to open the site it still trying to connect to old databases as if I didn't change the wp-config.php file, I get this error
Can’t select database
We were able to connect to the database server (which means your username and password is okay) but >not able to select the v3GMwXpnRQjq database.
Are you sure it exists?
Does the user zJ6epncZUYcQ have permission to use the v3GMwXpnRQjq database?
On some systems the name of your database is prefixed with your username, so it would be like >username_v3GMwXpnRQjq. Could that be the problem?

Error database connection is missing while using cae bake

I'm trying to bake my models, controllers and views using 'cake bake'.I entered default when it promp for database configuration. Then the command prompt displays an error message saying
Database connection "My sql" is missing or could not be created.
I have edit the path to environment variables as follow;
;C:\wamp\bin\php\php5.4.3;C:\wamp\www\fit or fat\lib\Cake\Console;
I have no idea what about what I should do.
Open the CakePHP site in your browser and go to Documentation / Book / Getting Started/ CakePHP Database Configuration. You'll find an explanation on what file you need to edit to provide your database credentials.

laravel4 migration failed (pdo exception)

I just used artisan migrate to create some table, but I get an error of Type PDO:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
A php/mysql testscript could connect to the database just fine, but it was another virtualhost and it did not use PDO.
In Laravel4 edited app/config/local/database.php to set the password and database name.
edit in start.php
UPDATE
I hardcoded the password in the PDO connection array and now terminal says there is no database named "database". Clearly it is looking somewhere else for the config, but I have no other config file.
(Due to following a tutorial about making a "local" directory it was not working for me)As it stands, I have downloaded the stable version and everything is working great.
I am going to delete this post, to keep the forum clean.
Make sure you have set up your database connection correctly in app/config/database
Laravel Database Docs
Make sure you are setting up a 'local' environment in start.php
Otherwise Laravel will look for DB config in app/config/database.php
Kindly Check Your app/config/database.php file in local host.
1.)Make Sure local Host Data Base name is Correct
2.)Make sure local Host Data Base username is correct.
3.)Make sure local Host Data Base password is correct.

issue creating new db in wordpress mysql

I'm working on a WordPress theme that requires a db in mysql to store lots of data.
I'm currently working on an installation script to install the theme. I have written a function to create a new db in the same mysql that WordPress uses it self.
Every time i run the script, i get redirected to a page stating that WordPress is already installed. But I'm not trying to reinstall WordPress, just create a new db in the same sql that WordPress uses.
I have also written a function to create new tables, which works fine so I'm sure there is no issues with connection.
If this helps, here is the function:
function create_db_mysql(){
require ('con_db_var/db_4216841335655434.php');
$connect = mysql_connect($db_host,$db_user,$db_pswrd) or die(mysql_error());
mysql_query("CREATE DATABASE theme_db",$connect);
mysql_close($connect);
}
I fetch the db info from wp-config.php.
so in the db_4216841335655434.php:
require ('../../../wp-config.php');
$db_host = ( DB_HOST );
//etc etc....
when i call the create_db_mysql(), I get taken to a page telling me that WordPress is already installed and then followed by instructions on how to re-install.
any ideas?
thanks!
Database creation and table creation are different levels of privileges. Many shared hosting providers will not give PHP the access to create a database.
So you might need to use your hosting providers control panels to create the database.

Categories