Importing sql dump file into PHPMyAdmin - mysql

Here is what I am dealing with, and I apologize for not being very sure of what I am doing.
I am trying to import a sql database dump file into xampp so that I can run a friends application.
I cloned the repository and put the code base into my htdocs folder. However, it needs to communicate with the database to run.
I have the dump file however when I go to import it I get the following:
Error
SQL query:
DROP TABLE IF EXISTS `sl_address`
MySQL said: Documentation
#1046 - No database selected
Do I need to create a database to dump into before I import the sql dump file? If so, does it matter what I name it, if it does how do I know what to name it?
I imagine if I don't name it correctly that the application won't be able to communicate with it.
I am really new to all this so I appreciate any help I can get. Thank you!

I think you need to create a database and select it before you run the SQL script that was generated by the dump.
Something like this:
create database newdb;
use newdb;
then the rest of your script.
Bobby

Related

Best approach to working with multiple developers and databases

I've been working on a project for a couple of months now with a few other developers and it has got to the point where we all have different changes to the DB we are working with, but all of the changes are local, meaning the server is out of sync with all of our local changes.
What is the best way to handle this? At the moment I tried to basically export my database from my local PC with phpMyAdmin and import that .sql file into the database on the server but as some of the tables already exist on the server it just gives out an error...
Would I have broken my database on the server by trying to import that sql file?
What do I do?
Ok so here's what I would do in your position...
Use this tool: http://www.clevercomponents.com/downloads/dbc/dbcdownload.asp
With the database compare tool, it should identify the differences in structure between two databases.
This generates an SQL file which will alter the target (your server) database to match the master (your local).
Always backup your target database before attempting something like this, just in case it goes wrong.

Exported all MySQL databases to a single file

Accidentally I exported all my mySQL databases to a single .sql file. I want to create those databases again in my development environment. When I try to import the file via PHPMyAdmin I get the following error message:
What should I do? Could you please help me?
If you look at the error, it says no Database selected.
You need to create an identical Database and import it from their.
You cannot just import a whole database, as it does not work.
Let me know if this solves,
Bryce
*also, make sure the files are speared by database, as this could make the error also, as the import can only import one in one file

How to copy mysql database file to your project folder?

Hi Friends I'm new to mysql but i know how to create user,database, table etc.
Earlier i use to work with ms access as backend. In ms access i had .*mdb file which i can put in my project folder and give it to anybody, so that the user can use my application without worrying about database.
but in MySQL i don't know how to copy database file and put in my project folder so that i can give it to other. and they can use my application without any worries......
plz help.... tell me if i'm wrong in my concept.....
Thanks in advance :))
You use mysqldump to dump the structure and contents of the database into a file, and then give that to the other person to load into their database server.

Migrating MS SQL to MySQL using MySQL Workbench causes a permission error

I have been working on this all day and now I'm stuck, so hopefully someone out there can help me :)
The challenge.
Migrate data from MS SQL to MySQL.
The MS SQL I received as a bak file, which I restored using SQL server management studio on a PC with Windows 7 Home edition.
I have created a source MySQL database on a webserver, running LAMP.
The solution (maybe)
I'm currently trying to convert the database, initially just one table for testing, using MySQL Workbench with the database->migrate wizard, but now I'm stuck at the Bulk Data Transfer. I would expect this step to create the table in my MySQL database and transfer the data, but that never happens.
For the source I choose Connection Method = ODBC (native)
No problems connecting to the source and destination databases
I choose to keep schema info as table prefix, so imported tables look like: database.dbo_table_name
Migration step succeeds (migrate selected objects & Generate SQL Create Statements)
The Create statements look like this if I don't edit them
CREATE TABLE IF NOT EXISTS 'restored_database_name'.'dbo_table_name' … I think the 'restored_database_name' part causes a permission error. It does if I type this in the SQL tab directly in phpMyAdmin. Therefore I change it to:
CREATE TABLE IF NOT EXISTS 'dbo_table_name' …
Also per default this is part of the SQL:
DROP SCHEMA IF EXISTS 'restored_database_name';
CREATE SCHEMA IF NOT EXISTS 'restored_database_name …
I think this also causes some permission issues, so I commented these out.
In the next step I uncheck the 'Create schema in target RDBMS' since I don't think I want this.
The problem:
Nothing interesting for the next steps, but then at the "Bulk data Transfer" I get this error:
ERROR: 'restored_database_name'. 'dbo_database_name': mysql_stmt_prepare: SELECT command denied to user 'mysql_user_name'#host' for table 'dbo_database_table_name.
Finished copying 0 rows.
I think the error is somehow related to permissions on the destination database. I wonder if it is possible to make sql file, not just with the create table commands, but also with INSERT commands so I could just take the sql and import it using command line or phpmyadmin.
I'm using Workbench 5.2 CE
Any help is appreciated
I've seen that you have made your way into the Workbench's Migration Wizard. Maybe you're just missing something so I suggest you to review this blog so you can verify your steps: How-To: Guide to Database Migration from Microsoft SQL Server using MySQL Workbench.
Unfortunately you can't use the Migration Wizard data copy command line utility to generate the SQL file with all the inserts, but I'm pretty sure you can get this from MS SQL Server Management Studio and it should pretty much work for MySQL without modifications (or with minor modifications).

Possible to patch a mysql sql file without using phpmyadmin?

If I have a cms, shopping cart, or some db based web script and lets say it has a database with like 50 tables
If I have a .sql file (call it patch.sql) that has a few ALTER commands and some UPDATE commands, I can goto phpmyadmin, import the patch.sql file and it will "apply" the changes to my db.
But lets say I export my db to a mydb.sql file first
Is there a way to "apply" the changes from "patch.sql" to "mydb.sql" without using a database?
I figured some command line like
mysql.exe merge patch.sql mydb.sql
or something but I didn't see anything like that.
Is phpmyadmin with a database the only way?
If your goal is to be able to later reimport mydb.sql and get the patched version of the database, then no, there are no tools to do that. patch.sql may has altered the structure of the database as well as the data itself based on your description. What you should do is apply the patch to your database, then export your db to a new .sql file.