How to run a php code with amazon rds instance? - php

So i have successfully, created a db instance with minimum security,database is postgres, and pgadmin4 is showing my remote db instance, i also have created a table in my db instance using that pgadmin, and the dbinstance log has shown the changes made. Now how to run a php script for a simple database operation? where should i paste the .php file ? Like what to do after this?

Related

Generate and Download SQLite DB

I am doing a project where a certain user can actually get/download a configuration file which is in sqlite(.db)form.
Is there any possibility where a PHP can compile the data into sqlite and directly serve it to the user?
What I knew is the PHP can actually create an sqlite db in the server. And I find it inefficient for my instance.

Php Copy database to a duplicate using cpanel xaml API or something similar

I have two databases for my website. One I run my live website and the other I run a development website. My need is to copy the live database to dev database everyday.
Is there some xml API to achieve this, which will copy my database to another whichever name I want and then rename it further according to my needs.
I have to achieve this entirely using php (No Phpmyadmin interface).
I tried BigDump.php but since my database size is more than 100MB the script breaks.
For this task, I will suggest you please setup cron through cPanel and use mysqldump command for the backup and restart that with mysql command.
You can create simple bash script for this task and setup that script in cron with everyday setting

CodeIgniter: Executing database script at the startup of application

I have just started using CodeIgniter for my PHP application. I need some help regarding database creation. Instead of creating database manually is it possible that when CI application in installed on any server then after starting the apache server, my application should execute some db script file to create DB structure if the DB is empty otherwise skip the DB creation. So every time when the apache server is started or restarted, my CI application should execute this script and check whether the database structure is up to date or not and create it if does not exist or not up to date.
This way I want to make sure that after first install or everytime the application runs the DB is created and ready to use.
Hope I have explained my requirement clearly. Please let me know if any kind of configuration will help me here.

How to Import Local MySQL Database to Web Server

I have a database with two tables in it, and I have exported them into a "dump.sql" file in my computer.
I am using a free web hosting service (000webhost.com) and I have a database named "username_newdb" and I want the two tables to be imported in that database.
I tried "Import" from phpmyadmin page, but it gives the error access denied for user, I don't know why. Moreover, I prefer to import the tables into new database, not to import (and create) the whole database. Can I do this? Maybe with PHP code?
If not, creating a new database would be accepted, too.
Any help would be appreciated.
if you can connect to that database from your computer directly, you can use any mysql manager to do the import, assuming your login/password is right as backup sql is just text file with bunch of INSERTs and CREATE TABLEs (so basically phpmyadmin should not even complain).

Build database with .sql file with PHP

Ok, i have searched high and low and have been unable to find an answer that works for what i am trying to do. I have two databases, we'll call them DB1 and DB2. I have a cron job that runs every night at 4am that backs up DB1 and stores its data in a SQL file archive, we'll call this file db_backup.sql. The file is stored in a folder on the server, we'll call it ROOT/backups/db_backup.sql.
Info
database names: DB1 and DB2
backup filename: db_backup.sql
backup file path: ROOT/backups/db_backup.sql
What i'm trying to do:
I want to use the db_backup.sql file to build DB2. I am basically trying to set up database replication where i replicate DB1 out to DB2. Don't know of any other way to do this on shared hosting servers than what i'm trying to explain. I am trying to use php to import the db_backup.sql file into DB2.
My Environment:
The website and databases are on a shared hosting account with godaddy (yes, i would love to get dedicated servers to set up real replication, but can't afford it for now). The databases are mysql in phpmyadmin.
Is this something that is possible? Any help would be greatly appreciated! Let me know if you have any questions as well.
I'm not sure if I understand your problem. You need to copy the db_backup file to the second host where you have access to the database and load the sql file.
From a shell:
mysql -hhost -uusername -ppassword databasename < db_backup.sql
This will restore the tables on the second machine.
Should be as simple as, setting up a CRON job on server 2 to call a script on Server 1 which dishes out the SQL file, then that cron job script would import / rebuild the DB.
Make sure to require a hash (via get or post) before giving out the DB SQL on server 1, or else anyone could read it / have your database dump.
Can you not avoid PHP altogether and connect directly to the database remotely to perform the backup either via the command line or using a scripting language more suitable for long running processes?

Categories