JavaChap Blog Java and Technology musings for the masses

15Nov/100

MySQL Import and Export

Here are few MySQL Queries/commands that i regularly use for exporting and importing MySQL data.  This is for my reference, but just thought this might be useful for newbies.

MySQL Table Data Export and Import
  • To export the just table data please use the following query
    SELECT * INTO OUTFILE 'data.txt' FIELDS TERMINATED BY ',' FROM mytable;
    
  • To import the csv file into table execute the following SQL Query.
    LOAD DATA INFILE 'data.txt' INTO TABLE mytable FIELDS TERMINATED BY ',';
    
Copy the contents of one database to another
  • First, create the new database
    create database db2;
    
  • Then, from the command-line, do the following to copy the contents from db1 to db2.
    $ mysqldump -u root --password=pass db1 | mysql -u root --password=pass db2
    
MySQL Dump
  • To export the MySQL database into a dump file, please execute the following command
    $ mysqldump -u root --password=pass db1 > dbdump.sql
    
Create MySQL User
  • Creating MySQL user and granting access
    CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'myuser';
    GRANT ALL ON *.* TO 'myuser'@'localhost' IDENTIFIED BY 'myuser';
    
30Jan/104

Eclipse ER Modelling(ERD) Plugin – ERMaster

Last week i need to design a schema for a new project at work. And my client wants us to use all open source tools. Eclipse being our IDE i had spent some time finding good Eclipse plugin for ER Modelling.

After trying about 4 to 6 plugins and reading about there features, I found that ERMaster is best available plugin for the ER Modelling. Here are some of the features that ERMaster supports.

  • Supports all primary databases (Oracle, MySQL and PostGreSQL)
  • Ability to import existing database (Reverse Engineering)
  • Export to various formats (Java, Excel, PNG and HTML)
  • DDL generation
  • Physical and Logical View
  • Group Management and History Management

Installation steps can be found here

Sample ER