How to export and import MySQL data on SSH

Source: Internet
Author: User
Tags vps
In this article, we take the LNMP environment as an example. If you export and import data to the MySQL database, you must first think of using phpMyAdmin. Yes, phpMyAdmin is very convenient, but when the database itself is relatively large, for example, there are hundreds of megabytes, so it is a bit sad to get the local upload and import. So today we will share with you how to export and import MySQL databases after logging on to VPS through SSH. Because both the export and import operations are

In this article, we take the LNMP environment as an example. If you export and import data to the MySQL database, you must first think of using phpMyAdmin. Yes, phpMyAdmin is very convenient, but when the database itself is relatively large, for example, there are hundreds of megabytes, so it is a bit sad to get the local upload and import. So today we will share with you how to export and import MySQL databases after logging on to VPS through SSH.

Because the export and import operations are very simple, they are just a line of commands.

First, log on to the VPS through SSH and export the database. command format:

/Usr/local/mysql/bin/mysqldump-u (username)-p (password) (database name)>/home/wwwroot/zr. SQL

I would like to add a description of the above line of commands.-u is followed by a space, followed by the database username, and-p is followed by no space. connect directly to the database password, and then enter a space, database name, space, followed by the following content, where zr. SQL is your own name.

Importing on other VPS is also very simple. command format:

/Usr/local/mysql/bin/mysql-u (user name)-p (password) (database name)

The format is the same as that of spaces.

I also run these commands on VPS, as shown in a figure.

In, I have a database on VPS, whose name is zr. the user of this database is zr, and the password is 12345678.

In fact, if they are all LNMP environments, there is another way to copy the/usr/local/mysql/var/(database name) folder to the new VPS, this solution can also save a lot of problematic databases.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.