How to Import export MySQL database from command line
|
|
This tip would be useful for those who are either making backup of their remote mysql database or moving their web hosting to their provider.
Here’s how to export mysql DB to SQL file using command-line utility :
mysqldump –user=username –password=1234 –databases your_database –opt –quote-names –complete-insert > example.sql
Here’s how to import the SQL back into mysql database :
mysql –user=username –password=1234 –databases your_database –host=mysql_server host
Don’t forget to add your ip address to the list of allowable host on the remote MySQL server!
Tags: commandline, database, db, guides, linux, mysql, opensource, tips, unix, webhosting, webserver
Keep updated with the latest posts, be a part of over 1,000 subscribers! :
Subscribe to your email
You might also want to read...
- How to optimize MySQL tables automatically using cron
- Sun Going to Acquire MySQL for USD 1 Billion
- A stressful day with the Oracle
- Import Blogger.com post & comments to WordPress
- SQLyog – Open Source MySQL Manager GUI for Windows
- How to use apt-get behind proxy server (Ubuntu/Debian)
- Twitter Command Line Client


January 19th, 2009 at 1:41 pm
Nice one. Thanks.
//Jadu, unstableme.blogspot.com
January 28th, 2009 at 5:19 am
I use it nice article thank you
March 18th, 2009 at 11:05 pm
I’ve also used
mysql -u username -p databasename > backup.sql
May 8th, 2009 at 1:43 am
I need try this. This is interesting.
May 26th, 2009 at 11:55 pm
mysql -u username -p databasename > backup.sql
thanks
June 29th, 2009 at 2:01 pm
Thanks a useful document
Dedicated Colocation Voip Datacenter
March 9th, 2011 at 1:20 am
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.sql.*;
import java.util.*;
class Login
{
public static void main(String[]args )
{
loginfrm frame=new loginfrm();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class loginfrm extends JFrame
{
public loginfrm()
{
setTitle(“translate”);
setSize(275,100);
ActionListener listener1=new CommandAction1();
ActionListener listener2=new CommandAction2();
panel1=new JPanel();
panel2=new JPanel();
JLabel LogLabel = new JLabel(“ENGLISH :”);
Lname = new JTextField(“”,100);
JLabel Result = new JLabel(“Result”);
panel1.add(LogLabel);
panel1.add(Result);
panel1.add(Lname);
add(panel1);
buttonOK =new JButton(“OK”);
buttonOK.addActionListener(listener1);;
panel2.add(buttonOK);
buttonCancel =new JButton(“CLOSE”);
buttonCancel.addActionListener(listener2);;
panel2.add(buttonCancel);
add(panel1,BorderLayout.NORTH);
add(panel2,BorderLayout.SOUTH);
pack();
}
private class CommandAction1 implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
String lname;
lname=Lname.getText();
try
{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
connstring=”jdbc:odbc:LOG”;
conn=DriverManager.getConnection(connstring,”",”");
stmt=conn.createStatement();
}
catch(Exception e)
{
System.out.println(“Error in program “+e.toString());
}
try
{
rs=stmt.executeQuery(“SELECT KANNADA FROM LOGIN where ENGLISH=’”+lname+”‘”);
while(rs.next())
{
System.out.println(rs.getString(1));
}
}
catch(Exception e)
{
System.out.println(“Error while trying to display table”+e.toString());
}
}
}
private class CommandAction2 implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
System.exit(0);
}
}
private JPanel panel1,panel2;
private JLabel LogLabeL;
private JButton buttonOK,buttonCancel;
private JTextField Lname;
String s;
static Connection conn=null;
static String connstring, sqlD;
static Statement stmt;
static ResultSet rs;
}
can you please tel me how to connect mysql to linux fedora10 with the help of this program??
August 31st, 2011 at 12:52 am
very well explained tutorial
@Ranjitha read javadoc for DeviceManager, it might helpful