Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import an existing database into netbeans

Tags:

java

mysql

I had created a database using mysql workbench and i saved that database in one of the local drives. So in netbeans I need to design a database which is same as the earlier (created by using mysql workbench). So I would like to import that database into netbeans. Can anyone explain the procedure to do so?

like image 908
SachinFederer Avatar asked Dec 06 '25 20:12

SachinFederer


1 Answers

A couple of days back I faced the same problem and found a easy solution. Though this question is asked 2 years back, I am posting this answer because it still doesn't have an answer here, so that it can provide help to other people with same problem in future.


I assume you know how to configure MySQL server. If no, visit https://netbeans.org/kb/docs/ide/mysql.html and follow the 'Configuring MySQL Server Properties' part.
After you create the server, right click on the 'MySQL Server'->'Create new database'. Give the database same name as the existing database has.
Now create a connection to the newly created database. If you dont know how, see the 'Starting the MySQL Server' and 'Creating and Connecting to the Database Instance' from https://netbeans.org/kb/docs/ide/mysql.html.
Now Expand the newly created connection which will look like 'jdbc:mysql://localhost:(portNumber)/(databaseName)'. Expand the database name node and right click 'table' and select 'Execute Command'
A new window will open. Assuming that you have a .sql file(Or may be a file without extension but consisting of SQL commands. You can export the database in file using your current admin tool if you have not already). Open that file in editor(notepad) and copy paste everything in the new opened command window in Netbeans.
Before Executing, just add one line before which states which database to use to execute query on.

USE <newly_created_database_name>;

as shown in the screenshot below (Red mark), it should be before the first line of the copy pasted SQL commands.
enter image description here
Now Execute the commands using the 'run SQL' button (green mark in image). To check, expand the tables node to see all the tables in original database are created. Now you have your original database in place to work with.

like image 82
Kashyap Kotak Avatar answered Dec 08 '25 16:12

Kashyap Kotak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!