MySQL database management common commands _ MySQL

Source: Internet
Author: User
Common MySQL database management commands: bitsCN.com

Guide: common commands for MySQL database management.

Install Mysql using the RPM Package and set iptables for TCP port 3306.

Root password Management sets the root user password mysqladmin-uroot password.

Modify the password of the root user mysqladmin-uroot-p password.

Database and table management go to mysqlmysql-h hostname-uroot-p.

Create mysql> create database location.

Import the data structure mysql-uroot-p location <./location. SQL.

View the database mysql> show databases;

Enter a database mysql> use location;

View table information mysql> show tables;

View the table structure mysql> desc Contact;

Change the table name mysql> rename table Contact to Contact_new.

Delete database mysql> drop database location.

Delete a table mysql> drop table Contact.

The authorization section creates a user and authorizes mysql> grant all on location. * to gk1020@10.1.11.71 identified by gk1020.

Unauthorize mysql> revoke all on location. * from gk1020@10.1.11.71.

Refresh the permission mysql> flush privileges.

The operation statement queries mysql> select * from Contact.

Mysql> select count (*) from Contact.

Modify mysql> update Contact set RegTime = '2017-01-01 00:00:00 'where id = 1.

Mysql> update Contact set RegTime = '2017-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 the exported database locationmysqldump-uroot-p location>./location. SQL.

Export a table mysqldump-uroot-p -- database location -- table Contact>./contact. SQL.

Export the database location data structure mysqldump-d-uroot-p location>./location. SQL.

Copy table copy table Contact is Contact_bakmysql> create table Contact_bak as select * from Contact.

Copy the table Contact structure mysql> create table Contact_bak as select * from Contact where 1 = 2.

View the running task mysql> show processlist.

BitsCN.com

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.