How to Import Local MySQL Database to Web Server - php

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).

Related

Working with .sql file

I'm having an old project which have server language is php. The project have .sql file database. How can we deal with this .sql file (i.e open in database program like MySQL workbench) to see the list of table and the corresponding data type, and real data type store in that table?
Any help is much appreciate.
P.S.: My php folder is zip and download from production server. I need to find out the incorrect data in .sql table (i.e see table content, real data inside)
.sql file is actually a database dump. You will have to import it using any MySQL management tool like phpmyadmin or MySQL workbench. See this thread
How can I import data into mysql database via mysql workbench?

MySQL / PHPMyAdmin

I've recently taken over a WordPress site from another 'dev' company. The site is highly unstable and not delivering what the client needs. So, I'm currently trying to export the site wholesale to one of our company server.
Numerous backup plugins have failed for various reasons, so I'm now trying to get an export of the MySQL database via phpmyadmin to import into our MySQL server. I've taken a full export from the old server and tried importing it into the new server via phpmyadmin . However, this fails after a period of time, with no real indicator of why.
Next, I exported every table individually and tried to import them to the new server. The first 2/3 or so appear to work but then the latter 1/3 all fail to import with the output/error message saying that the table has multiple primary keys declared.
I really need to export the database structure and data from the old server and transfer it to the new one. So, I'm really perplexed as to what my next move could be. If these tables have multiple primary keys and this prevents an import, how were they created in the first place??
What can I do to remedy the situation and get the data migrated?
This could be a problem of the dump you get. If it was too big, your phpmyadmin would just break down after a while. If you have ssh access to your server you could easily import your dump by shell after uploading your dump file to your server. If this is not possible you could maybe work with a big dump script http://www.ozerov.de/bigdump/ which automatically imports the dump partially, so there is no server timeout anymore.
It appears that this was related to some limiting factor with PHP / phpMyAdmin. I was able to import the generated SQL scripts via the SQL tool in Virtualmin / Webmin without any apparent issue.

Is there a way to create a linked table in a mysql database?

I work often in MS Access and I always create linked tables to csv or txt files so that when some part of data changes in a source file the change appears in the dtb as well.
Is there a way to create linked tables in a mysql database used for storing data for php page?
Can phpMyAdmin in xampp do this?
MySQL supports a CSV storage engine.
Read the documentation here for more details:
http://dev.mysql.com/doc/refman/5.6/en/csv-storage-engine.html
So you can create a table that is linked to a CSV file, and if you modify the file, the new data will immediately become visible to SQL queries.
Yes, you can create a linked table to MySQL in Access. You will have to install the MySQL driver on the user's machine, and setup an ODBC. Then you can create a linked table to that ODBC connection.

How to Synchronize mysql databases between local and hosted servers automatically?

I would like to synchronize local Mysql db with remote Mysql db.
Due to internet fail, we have to use local application. Once internet problem solved, db should synchronize with remote db.
Because we are using same application in local and remote.
You can use SQLyog which has Database synchronization feature to sync two databases if you are looking for open source tool then refer pt-table-sync http://www.percona.com/doc/percona-toolkit/2.1/pt-table-sync.html
You can make the dump of your local database, and import that on the hosted server when ready.
I think I would create a table changes on a local database and whenever I do any change on the database, it is also saved in the changes table.
For synching then, I'd
loop through changes table and make query-like string
copy it to a clipboard
Have a page on a hosted web with input where to paste that string
When submitted, PHP explodes the string into different queries
Loop through queries and perform them against a hosted database
Of course, here intensive validation should be considered to ensure that the pasted text is a query string copied from the local server
I am afraid you need to do the export and import thing. Don't think there is any automatic kind out there..erm, i would like to know as well

Get old MySQL data from old mysql folder and import into new database

On my older computer's HDD, I have WAMP5 installed with MySQL and PHPMyAdmin. The data is in the folder. How do I get that data that is in three files? The data is at E:\wamp\bin\mysql\mysql5.5.24\data\fbdb, I can see it.
I want to import the country table to the fbdb database, these are the files I have from it: country.MYD, country.frm and country.MYI
What do I do with these files to add to new database?
Assuming you've created an 'fbdb' database on the new computer, just copy the country.* files you've found into the 'fbdb' folder under your new machine's MySQL data directory, and restart the MySQL server -- as long as it's the same version or newer as the MySQL server on which the table was created, this should be all you need to do, as the MySQL engine will automatically check, and if necessary update, the 'country' table from those files.
You should export and then import the desired parts of your database from your old disk to your new disk, or even the whole database. First you export what you need into a file then you can use that file to import it into the database. Read this forum thread for more information.

Categories