How to install mysql database under Ubantu, and how to back up SQL files and run SQL files !, Ubantumysql

Source: Internet
Author: User
Tags import database

How to install mysql database under Ubantu, and how to back up SQL files and run SQL files !, Ubantumysql
Installing mysql on ubuntu is actually easier than installing mysql under Windows. Just enter the password once in the middle of the following commands. Other operations are automatically completed. 1. sudo apt-get install mysql-server 2. apt-get isntall mysql-client
3. sudo apt-get install libmysqlclient-dev

After installing mysql, check whether the installation is successful:Sudo netstat-tap | grep mysql

After the check is successful, it is a simple test.
Mysql-u root-p

Other operation commands are the same as those in time.

The following describes how to export database files and import database files:

1. Use the mysqldump command to export the database (note the installation path of mysql, that is, the path of this command ):
1. Export data and table structure:
Mysqldump-u username-p Password Database Name> database name. SQL
$/Usr/mysqldump-uroot-p abc> abc. SQL
After you press enter, you will be prompted to enter the password

2. export only the table structure
Mysqldump-u username-p password-d Database Name> database name. SQL
$/Usr/mysqldump-uroot-p-d abc> abc. SQL

Note:/usr/---> mysql data DIRECTORY

Ii. Import Database
1. First, create an empty Database
Mysql> create database abc;

2. Import Database
Method 1:
(1) Select a database
Mysql> use abc;
(2) set database Encoding
Mysql> set names utf8;
(3) import data (note the path of the SQL file)
Mysql> source/home/abc. SQL;
Method 2:
Mysql-u username-p Password Database Name <database name. SQL
# Mysql-uabc_f-p abc <abc. SQL

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.