MySQL Common operations

Source: Internet
Author: User

Set the MySQL environment variable [[email protected]~]# echo  "path= $PATH:/usr/local/mysql/bin"  >> /etc /profile[[email protected]~]# source /etc/profile[[email protected]~]# mysql - Uroot -p ' passwd ' mysql> querying the current library mysql> show databases;+--------------------+| database            |+--------------------+| information_ schema | |  mysql              | |  test               |+-------- ------------+3 rows in set  (0.06 sec) queries a library's table Mysql> use mysql;database  changedmysql> show tables; View all fields of a table mysql> desc slow_log;mysql> show  create table slow_log\G; See which user is currently mysql> select user (); View the currently used database mysql>  Select database (); Create a new library mysql> create database db1; query ok, 1 row affected  (0.05&NBSP;SEC) creates a new table Mysql> use db1;database  changedmysql> create table t1  (' ID '  int (4),  ' name '  char (40)); query ok, 0 rows affected  (0.02 sec) View current database version mysql> select version ( ); View current MySQL status mysql> show status; view MySQL parameters mysql> show variables; Create a regular user and authorize mysql>  grant all on *.* to  ' Test ' @ '% '  identified by  ' 123 '; query ok, 0 rows affected  (0.01 sec) query statement mysql> select count (*)  from mysql.user;mysql> select * from mysql.db;mysql> select db  from mysql.db;mysql> select db,user  from mysql.db;mysql>  select * from mysql.db where host like  ' 10.0.% '; Insert a row Mysql> insert into db1.t1 values  (1,  ' abc '); query ok, 1 row affected  (0.02 sec) mysql> select * from  db1.t1; change a row of a table mysql> update db1.t1 set name= ' AAA '  where id=1; query ok, 1 row affected  (0.01 sec) rows matched: 1  changed:  1  Warnings: 0mysql> select * from db1.t1; Clear Table Data mysql>  truncate table db1.t1; query ok, 0 rows affected  (0.01&NBSP;SEC) mysql> select count (*)   from db1.t1; Delete Table mysql> drop table db1.t1; query ok, 0 rows affected  (0.00 sec)   Delete database mysql> drop database  db1; query ok, 0 rows affected  (0.02 sec) Backup:[[email protected] ~]#  Mysqldump  -uroot -p ' YourPassword '  mysql >/tmp/mysql.sql recovery: [[Email protected] ~]# mysql -uroot -p ' YourPassword '  mysql </tmp/ Mysql.sql


This article is from the "Linux_config" blog, make sure to keep this source http://jialiang1026.blog.51cto.com/10119067/1632205

MySQL Common operations

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.