How to upload database(php)? - php

I have develop one web site in php.
I know how to upload it using ftp(filezilla).
But i dont know how to upload database and i can't do any thing without uploading this database.
please help me to upload my database.
Thank you.

tl;dr version
Ask your hosting provider what methods they support.
More detail
It all depends on your hosting. Do you have a simple hosting account with only FTP access (i.e. no command line or remote desktop access)? In these cases your host usually has phpMyAdmin installed or an alternative web based database management system.
It's unlikely, but you could also try connecting to your MySQL database from your computer. You can download the command line tools or simply get MySQL Workbench, and put in your hostname and test the connection.
If you do have shell access, you can dump your local database with mysqldump and upload the resulting SQL file, then import that on the server. A similar technique can be used with remote desktop.

Normally you could make a gzipped .tar.gz of your DB dump and upload it with a file client to your space... once done unzip it and restore from dump using a mysql commandline or some GUI provided by the site admin.. i'm assuming your DB is MySql as its the obvious choice and you have the privilege to access the DB.... this question seems more suited for serverfault as it seems to have less relation to programming in general. Anyhow
To Tar:
tar –cvzf tarfilename foldername
Untar:
tar –xvzf tarfilename
Example:
tar –cvzf abc.tar.gz abc
This will zip [tar] the abc folder with the name abc.tar.gz
tar –xvzf filename.tar.gz
This will unzip [untar] the file as abc folder.
To backup and restore from dump please refer this link as it has some brilliant illustration.

If you're using MySQL, just export the database from your localhost (phpmyadmin)(click on the database and then search for the export tab ).
When you export it, you need to import it to your online host (your domain).
And to do this, you have to have access to the cpanel of your host.
After logging in to your cpanel , search for phpmyadmin (or whatever database you're using).
Create a database and import your database.

Related

How can I push to a mysql database from Mamp to my domain?

I just made a blog post on my localhost machine (I.E. Draft) now I want to update the remote MYSQL database that is now running on the machine.
So in analgous terms when uploading the files, I just run PHPStorm and include upload to remote database, is there a way to do that or a PHP file that will administrate the process
My pseudocode guess will be:
localhost:admin.php
if publish clicked, connect to remote sql and copy entry.
If I understood correctly you need to remotely access your database right?
If so you have some options, starting with:
1) Use a tunnel over ssh with mysql workbench!
How? Example Here: Standard TCP/IP over SSH Connection Method
You can import your local database by reverse engineering and after that simply accessing to database menu, you can synchronise model with remote database etc. That is to grant that both databases have the same structure. You can put your sql and execute as well... there are plenty of options here.
2) You can also access your remote database with a data source under PHPSTORM. here it is how you can do it! Managing Data Sources
3) Via terminal, if you have access to root simple scp your sql file to remote and after that well update remote database.
Backup database: mysqldump -u username -p database_to_backup > backup_name.sql
Restore database mysql -u username -p database_name < backup_name.sql
4) Make you sql server accessible to the world (not recommended)!
Steps include creating a new user or upgrade an existent user privileges options are wide here.
Read this article: it says pretty much everything!
5) Install phpmyadmin (not recommended)

How to use a standalone database in a linux machine?

I have a linux machine server, I am able to use php in it. I can only connect to it using a putty command prompt or an FTP program. (basically have limited access).
Is there a way I can use a free database (like mysql)? I'm don't think I can install it on the root folders because of permissions, that's why I was thinking maybe there is a database tool that works as a standalone file, and each database is created as a resource file. That way there is no need for an installation, and you can keep the whole thing in some sub folder in the location where I do have access.
Is this possible?
I am hoping for something like, I download a file, place it on some folder after transferring it through FTP program. Then use php code to create a database and insert/delete records.
And every database created is stored as a file somewhere beside the database tool.
Use sqlite I think is just what you are looking for.
http://www.sqlite.org/about.html

Replicate / Backup Entire Site & SQL Databases To Remote Server With PHP Cronjob

I am trying to make a complete file & mySQL backup of my site each night.
I was thinking the best way of doing it would be to have a cronjob run each night that would login to a remote server and replicate all of the local files.
Then, I need to figure out a way to take backups of all the mysql databases (currently there are three) and upload them all to the remote server as well.
This sounds like a huge project and I don't know whether to reinvent the wheel here, or if there is some script out there which basically does the same thing already.
Use cronjob to run a bash script
mysqldump the databases
tar -cvf the files
wput it all to your remote server
Also you can set a variable like now=$(date +"%Y_%m_%d") to use in your file names
You can use the mysqldump command to backup the database to a file and then upload to a different server
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
have you thought about MySQL replication? Maybe that fits better to your needs and you doesn't need php to do it
http://dev.mysql.com/doc/refman/5.5/en/replication.html

Create .exe file in php with mysql database

i have developed in-house software for hotel management system using PHP/MYSQL. Our Client wants Software in .exe format and used in desktop. i use various softwares for .exe conversion but it only support php but i want's to connect with MySQL Database. Please anyone can help to create .exe conversion with MySQL Database..
Download PHP Desktop Chrome.
Copy all your code from site directory to Phpdesktopchrome/www directory.
Run Phpdesktopchrome.exe, it will execute like a browser with PHP compiler.
Download Innosetup Software for make exe file.
Install and run Innosetup and select Phpdesktop chrome files to create a EXE file in Option.
Install wampserver in client system with database import.
Enjoy.
There are many compliers available on web by which you can create EXE in PHP.
This program runs through dos and windows only... :) so this is good news for windows user
First Download zip from Here.
Now unzip it and open Command prompt and then go to its directory location.
Start -> run then type ‘cmd’
Use the “cd..” command to change directory.
Place PHP script to be compiled next to bamcompile.exe place it in same directory.
In the cmd prompt, at that directory, type:
bamcompile test.php
variations:
bamcompile -c test.php gives compression.
-e:something.dll allows a DLL to be embedded
Ready made examples are given in Zipped files which you have downloaded,just try it out.
Another application wapache is also there but i dont know much about it.
DOWNLOAD WAMP server from wampserver.com.
its very good for offline use server for desktop, then just copy and paste you script abd .sql file into it. and you are Done.
If your client using highspeed interenet then they can connect the server to online. but they need super computer for more traffic, another option is LAN.
If the program is for office use and no need to connect a lot of computer and internet then use LAN and WAMP.
------ Another possible you can use --------
Install WAMP then copy then .exe file "click start button > all program > and paste into startup folder". server will run automatic windows OS start or restart but it take 2-3 min. (green light)
go to wamp folder > www > make a folder for your program then paste your script.
open any browser then in address bar type "localhost or 127.0.0.1 (localhost IP for offline)" , scroll down and you will see "Your Projects" and under of this you will see your folder which you had create into wamp server > www folder. click on it and here you gooooo....
Now your client can do work with your script. Bookmark it and also create a shortcut into desktop for direct use.
Hope this may help you. thank you.
If you are getting any problem to do this work, then email me here - (krishnabiker#yahoo.com)
I think you should just convince your client not to use a .exe installer. It makes no sense.
You could have an installer that installs a local webserver and a local MySQL, and then opens a web browser and browses the local webserver. This would work, but it means your application runs on only one machine, and can't be used by two people.
On the other hand, you could install an application that talks to a central MySQL database, hosted on the LAN. But then why not install the entire application (webserver, MySQL etc) on the LAN, and have the clients access it across the LAN as a web application? Still no reason for a local install.
I would suggest:
See if you can persuade your client to move to an entirely web-hosted solution. Emphasize how easy updates are - from one central location, not from each machine; or
See if you client won't be happy with a .exe that installs a link to a URL (on the LAN).
VERY SHORT ANSWER: NOT POSSIBLE
Tell your client that it is a client-server application not a desktop app.
One idea is to have portable PHP/MYSQL/APACHE that can be stored in a CD or used and create an autorun fro it..
Tell your client you can do better than that, you can create a batch file for his use!
Then create a program.bat file with one line that runs the php (should be something like "php ").
:)
We need to bundle your project files in MSI ( windows installer ) along with PHP frameworks, MySQL and Apache.
Everything can be included in a single MSI file or you can keep server part in one MSI (PHP framework+Apache framework+ MySQL) and your Project file along with Yiiframework in another MSI.
I already made server part MSI in order to create one of my previous web project. In that project i had to configure Mysql DB (my.ini) and Apache configuration file (.conf). It worked fine.
For a desktop application I recommend that you change your database settings (if you can) and switch to SQLite3 DB. They are portable files and does not need a database server to run.
Use http://www.usbwebserver.com/ and from a stick or an CD/DVD you will be able to run your application. It is a portable version similar to W

How to download a live MySQL db into a local test db on demand, without SSH?

I have a fairly small MySQL database (a Textpattern install) on a server that I do not have SSH access to (I have FTP access only). I need to regularly download the live database to my local dev server on demand; i.e., I would like to either run a script and/or have a cron job running. What are some good ways of doing this?
Some points to note:
Live server is running Linux, Apache 2.2, PHP 5.2 and MySQL 4.1
Local server is running the same (so using PHP is an option), but the OS is Windows
Local server has Ruby on it (so using Ruby is a valid option)
The live MySQL db can accept remote connections from different IPs
I cannot enable replication on the remote server
Update: I've accepted BlaM's answer; it is beautifully simple. Can't believe I didn't think of that. There was one problem, though: I wanted to automate the process, but the proposed solution prompts the user for a password. Here is a slightly modified version of the mysqldump command that passes in the password:
mysqldump -u USER --password=MYPASSWORD DATABASE_TO_DUMP -h HOST > backup.sql
Since you can access your database remotely, you can use mysqldump from your windows machine to fetch the remote database. From commandline:
cd "into mysql directory"
mysqldump -u USERNAME -p -h YOUR_HOST_IP DATABASE_TO_MIRROR >c:\backup\database.sql
The program will ask you for the database password and then generate a file c:\backup\database.sql that you can run on your windows machine to insert the data.
With a small database that should be fairly fast.
Here's what I use. This dumps the database from the live server while uploads it to the local server.
mysqldump -hlive_server_addresss -ulive_server_user -plive_server_password --opt --compress live_server_db | mysql -ulocal_server_user -plocal_server_password local_server_db
You can run this from a bat file. You can ever use a scheduled task.
Is MySQL replication an option? You could even turn it on and off if you didn't want it constantly replicating.
This was a good article on replication.
I would create a (Ruby) script to do a SELECT * FROM ... on all the databases on the server and then do a DROP DATABASE ... followed by a series of new INSERTs on the local copy. You can do a SHOW DATABASES query to list the databases dynamically. Now, this assumes that the table structure doesn't change, but if you want to support table changes also you could add a SHOW CREATE TABLE ... query and a corresponding CREATE TABLE statement for each table in each database. To get a list of all the tables in a database you do a SHOW TABLES query.
Once you have the script you can set it up as a scheduled job to run as often as you need.
#Mark Biek
Is MySQL replication an option? You could even turn it on and off if you didn't want it constantly replicating.
Thanks for the suggestion, but I cannot enable replication on the server. It is a shared server with very little room for maneuver. I've updated the question to note this.
Depending on how often you need to copy down live data and how quickly you need to do it, installing phpMyAdmin on both machines might be an option. You can export and import DBs, but you'd have to do it manually. If it's a small DB (and it sounds like it is), and you don't need live data copied over too often, it might work well for what you need.

Categories