How do i open a schema in mysql workbench?

I'm trying to learn SQL and I downloaded a database to practice. I downloaded two files of extension .sql, one is the schema and the other one the actual data. I've also installed MySQL Workbench. I've been googling and I've been trying things to solve this but I don't understand Workbench and I can't load the database.

Where do I import the schema and the data in order to try queries ?

Any help would be really appreciated.

Mike Lischke

44.8k15 gold badges105 silver badges162 bronze badges

asked Oct 8, 2014 at 15:04

How do i open a schema in mysql workbench?

This is simple in Workbench, and I'll use the freely available sakila database as an example. Feel free to apply this to your situation:

  1. Download "sakila" from here: http://dev.mysql.com/doc/index-other.html
  2. Extract it somewhere, in my case, onto the Desktop into a new sakila-db/ directory
  3. Open Workbench
  4. In the Schema Navigator, right-click an empty area and choose "Create Schema"
  5. In the schema creation wizard, name it "sakila", keep the defaults, hit "Apply", finish wizard
  6. Go to "File" -> "Run SQL Script..."
  7. Choose "sakila-schema.sql", make sure "Default Schema Name" is blank or select "sakila", execute
  8. Go to "File" -> "Run SQL Script..."
  9. Choose "sakila-data.sql", execute
  10. Click the "refresh" icon in the Workbench Schema Navigator (or restart Workbench)
  11. Now, use the populated sakila database :)

Steps (4) and (5) are optional in this case (as executing sakila-schema.sql creates the schema), but the idea is worth mentioning.

Here's how it would look when loading th script into the SQL IDE:

How do i open a schema in mysql workbench?

Mike Lischke

44.8k15 gold badges105 silver badges162 bronze badges

answered Oct 9, 2014 at 4:47

Philip OlsonPhilip Olson

4,4321 gold badge23 silver badges20 bronze badges

1

The accepted answer is from 4 years ago, so I thought I'd give an update as in MySQL Workbench 6.3 the procedure is a bit different.

You have to select the menu item Server -> Data Import -> Import from Self-Contained File and select the SQL file containing the database you want to import.

In Default Target Schema, select the database you want to import the SQL dump to, or create a new empty database via New...

Then click on Start Import.

answered Mar 20, 2018 at 10:44

How do i open a schema in mysql workbench?

dr_dr_

2,2241 gold badge23 silver badges36 bronze badges

2

You could use mysql console from terminal. Login through the user id and pass. Then create a Database from the following command is the .sql file does not have one such command to create so.

Create database db-name
use db-name;
SOURCE xyz.sql;

Source command would load the the content from xyz.sql to your database created. This would be reflected later in workbench indeed.

answered Oct 8, 2014 at 15:10

Kumar KailashKumar Kailash

1,3471 gold badge10 silver badges19 bronze badges

5

Its very easy on Linux platform just follow below mentioned steps, After downloading zip file of sakila-db, extract it. Now you will have two files, one is sakila-schema.sql and other one is sakila-data.sql.


  1. Open terminal
  2. Enter command mysql -u root -p < sakila-schema.sql
  3. Enter command mysql -u root -p < sakila-data.sql
  4. Now enter command mysql -u root -p and enter your password, now you have entered into mysql system with default database.
  5. To use sakila database, use this command use sakila;
  6. To see tables in sakila-db, use show tables command

Please take care that extracted files are present in home directory else provide the absolute path of these files in all above commands.

answered Sep 18, 2015 at 14:00

How do i open a schema in mysql workbench?

alpha9eekalpha9eek

1,4392 gold badges11 silver badges10 bronze badges

How do I find my schema in MySQL Workbench?

From the home screen, right-click on a MySQL connection, choose Edit Connection, and set the desired default schema on the Default Schema box. The selected schema is displayed as bold in the schema navigator. Filter to This Schema: Enables you to target specific schemas in the list.

How do I open a new schema in MySQL?

Steps to create a schema in MySQL Open the MySQL Workbench. Click the Create Schema option. Provide a schema name. Click apply to create the MySQL scheme.

How do I show schemas in MySQL?

To show the schema, we can use the DESC command. This gives the description about the table structure.

How do I edit a schema in MySQL Workbench?

To change the name of the default schema, double-click the schema tab. This opens a schema editor window docked at the bottom of the application. To undock or redock this window, double-click anywhere in the editor title bar. To rename the schema, use the field labeled Name.