Jump to content

[SOLVED] Importing/Amending MySQL table


Grant Holmes

Recommended Posts

I have researched this high and low. There seem to be 1000 answers out there that unfortunately DON'T help me. My client is on a Yahoo server. They allow NO external access to the DB/table, so you must import from within PHPmyAdmin.

 

When I go to the DB and the Table I wish to import to, I must be able to browse to the file on my PC and upload it. No matter what I've tried 'fixes' from using Excel to create the file to using note pad... From using quotes to not using them, colons, commas, different extensions lik CSV & TXT, etc. No matter what I do, I get errors.

 

Surely there must be a simple way to do this. I even abandoned trying to import my bigger table just to import/upload a simple two field file with three records. ERROR. Usually a syntax error.

 

I have the DB and Table created. I have data in my working table and need to bring customer data into the table. In the case of my small test, the table it empty. Same results.

 

Any help? I've not seen any tutorial or exact instructions on how to prepare the file.

Link to comment
Share on other sites

In the mean time, I've gotten a bit of help that the file created needs to be a flat file (like text), with one line per record. So, I used this format to test my small test table. I made a text file like this:

INSERT INTO `test` VALUES ('Value1', 'Value2');

And named the file "test.sql"

 

I got back:

""INSERT INTO `test`

VALUES (

'Value1', 'Value2'

)

 

Error: #1046 - No database selected

==

 

How then do I select the database? In PHPmyAdmin, I was already inside the DB inside the table when I did the import??

Link to comment
Share on other sites

I don't see any way to perform what Barand suggests in Yahoo. In the example above, it appears I'm close, but the "no database selected" is obviously the stopping point.

 

When I'm in PHPmyAdmin, I go to the pull down on the left, select my database, then select my table, then click the "SQL" tab where I do the import. How can I not have the DB selected?? I don't get this. What am I missing?

===

Added:

Even when I research "import" on this MySQL page I see nothing about selecting the DB.

Link to comment
Share on other sites

Well, I figured it out. Here's the instructions for those as lost as I was (am).

 

First create the import text file of data to import. Make sure to have the field layout matching. Separate values with ";". So in my simple two field values test the data looked like this:

data1;data2

I saved my file with the extension of (sql) or "filename.sql" locally on my PC.

 

When in PHPmyAdmin, on the left, select your database (DB). then select the table you wish to import to.  In the upper left corner you'll see an SQL button under the PHPMyAdmin logo and click on that button.

 

It will open a separate smaller window. At the bottom of that window, you'll see a text link that says, "Insert data from a text file into the table"- Click that link. Back at the main page, PHPmyAdmin will open a screen where you can browse to upload your data, including changing many parameters. I changed nothing. I hit submit and the data was amended to my table correctly.

 

It shouldn't be that hard.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.