MySQL database management common commands

Source: Internet
Author: User

Reference: http://blog.linuxeye.com/419.html

Installation

Installing MySQL with RPM packages

Setting the TCP 3306 port iptables

Root Password management

Set the root user's password

mysqladmin-u root password ' password '

To modify the root user's password

mysqladmin-u root-p password ' password '

Database, table Management

Go to MySQL

Mysql-h Hostname-u Root-p

Create a database

Mysql> CREATE DATABASE location

Import data Structures

Mysql-u root-p Location <./location.sql

View Database

mysql> show databases;

Enter a library

mysql> use location;

View table Information

Mysql> Show tables;

View table Structure

mysql> desc Contact;

Change table name

Mysql> Rename table Contact to Contact_new

Delete a library

Mysql> DROP Database Location

Delete a table

mysql> drop TABLE Contact

Authorization section

Establish users and authorize

Mysql> Grant all on location.* to [e-mail protected] ' 10.1.11.71′identified by ' gk1020′

Cancel Authorization

Mysql> revoke all on location.* from [email protected] ' 10.1.11.71′

Refresh Permissions

Mysql> Flush Privileges

Action Statement

Inquire

Mysql> SELECT * FROM Contact

Mysql> Select COUNT (*) from Contact

Modify

mysql> Update Contact Set regtime= ' 2008-01-01 00:00:00 ' where id=1

mysql> Update Contact Set regtime= ' 2008-01-01 00:00:00 ', cid=1 where id=1

Insert

mysql> INSERT into contact values ("," ...)

mysql> INSERT into contact (id,cid,contact) VALUES ("," ...)

Delete

Mysql> Delete from contact where id=1

Export

Export Database Location

Mysqldump-u root-p Location >./location.sql

Export a table

Mysqldump-uroot-p–database location–table Contact >./contact.sql

Export data structure of database location

mysqldump-d-uroot-p Location >./location.sql

Copying tables

Copy table contact for Contact_bak

Mysql> CREATE TABLE Contact_bak as SELECT * from Contact

Duplicating the structure of a table contact

Mysql> CREATE TABLE Contact_bak as SELECT * from Contact where 1=2

View the tasks that are being performed

Mysql> Show Processlist

Description

Location for library name, contact for table name

MySQL database management common commands

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.