MySQL basic commands and the use of MYSQLADMIN commands

Source: Internet
Author: User
Tags create index mysql client mysql commands mysql host

Mysql

--user,-U

--host,-H

--password,-P

--port

--protocol

--database database,-D


MySQL Batch processing mode

[Email protected] ~]# Vim/test.sql


Create DATABASE TestDB;

CREATE TABLE testdb.tb1 (ID int,name CHAR (20))

[[email protected] ~]# MySQL

mysql> \. /test.sql

Query OK, 1 row affected (0.09 sec)


Query OK, 0 rows affected (0.29 sec)


mysql> drop database TestDB; #删除

Query OK, 1 row affected (0.25 sec)


mysql> show databases;

+--------------------+

| Database |

+--------------------+

| Information_schema |

| MyDB |

| MySQL |

| Test |

+--------------------+

Rows in Set (0.06 sec)


Or

[Email protected] ~]# Mysql-uroot-p </test.sql

Enter Password:

[Email protected] ~]# mysql-uroot-p

mysql> use TestDB;

Mysql> Show tables;

+------------------+

| Tables_in_testdb |

+------------------+

| tb1 |

+------------------+

1 row in Set (0.00 sec)



MySQL commands are divided into client commands and server-side commands, and server-side commands end; (default)


Status View Current state

\d modifier Terminator

\ r Reconnect to Mysql-server

\g Whatever the Terminator is sent to the server side to execute

\g Regardless of the Terminator is sent to the server side execution, and the result is displayed vertically @ very good \g and useful

\! Execute shell command directly

\c suddenly did not want to execute this command, with \c abort

-A, disable name completion by using-a when connecting to MySQL


Mysql> rehash using name completion will affect the speed

mysql> \d # Change command Terminator to #

Mysql> Show tables;

Show tables#

+------------------+

| Tables_in_testdb |

+------------------+

| tb1 |

+------------------+

1 row in Set (0.00 sec)


mysql> \! Ls/tool

apache-tomcat-7.0.73.tar.gz memcached-1.4.33

Crmsh-2.3.2-1.1.noarch_ (1). RPM mysql-5.6.34.tar.gz

crmsh-scripts-2.3.2-1.1.noarch.rpm nginx-1.10.2

Discuz_x3.2_sc_gbk_ (1). zip nginx-1.10.2.tar.gz

httpd-2.4.23 package.xml

jdk-8u112-linux-x64.tar.gz python-parallax-1.0.1-9.8.x86_64.rpm

Libevent-2.0.22-stable Readme

libmemcached-1.0.18.tar.gz xcache-3.2.0

memadmin-1.0.12.tar.gz xcache-3.2.0.tar.gz


[email protected] ~]# MySQL--html #将MySQL的输出格式改为html

mysql> use MySQL

Mysql> select User,host from user;

<table BORDER=1><TR><TH>USER</TH><TH>HOST</TH></TR><TR><TD >root</TD><TD>127.0.0.1</TD></TR><TR><TD>root</TD><TD> 192.168.%.%</td></tr><tr><td>root</td><td>localhost</td></tr> <tr><td>root</td><td>node1.zxl.com</td></tr></table>4 rows in Set (0.05 Sec


After saving the output in. html format, open the display as a table in a browser


Get help command

Such as

mysql> Help Select

Mysql> help CREATE INDEX get assistance creating indexes



Usage of the mysqladmin command


[[email protected] ~]# mysqladmin-uroot-p password ' 123456 ' Change password to 123456

Enter Password:

Change it back again.

mysql> Update Mysql.user set Password=password (' 123 ') where user= ' root ';

mysql> flush Privileges;

Mysql> \q

[[email protected] ~]# MySQL

Welcome to the MySQL Monitor. Commands End With; or \g.


Ping to see if the MySQL host is online

[[email protected] ~]# mysqladmin Ping

Mysqld is alive


[[email protected] ~]# mysqladmin create hellodb creating Hellodb Library

[[email protected] ~]# mysqladmin drop HELLODB Delete Hellodb library


Displays the status information for MySQL and can be displayed consecutively multiple times

[Email protected] ~]# mysqladmin status

uptime:16982 threads:1 questions:117 Slow queries:0 opens:88 Flush tables:1 Open tables:81 queries per second avg:0.006

[[email protected] ~]# mysqladmin status--sleep 1--count 5


Display state variables and their values

[Email protected] ~]# mysqladmin extended-status

+-----------------------------------------------+-------------+

| variable_name | Value

+-----------------------------------------------+-------------+

| aborted_clients | 0

| aborted_connects | 4 |

| Binlog_cache_disk_use | 0 |

| Binlog_cache_use | 0 |

| Binlog_stmt_cache_disk_use | 0 |

| Binlog_stmt_cache_use | 14 |

| bytes_received | 7104 |

| bytes_sent | 38911 |


Display Server Variables

[Email protected] ~]# mysqladmin variables

Refresh Authorization Table

[Email protected] ~]# mysqladmin flush-privileges

Close all open tables

[Email protected] ~]# mysqladmin flush-tables

Resetting the thread pool cache

[Email protected] ~]# mysqladmin flush-threads

Reset most server state variables to start counting from 0

[Email protected] ~]# mysqladmin flush-privileges

Shutting down the MySQL server

[Email protected] ~]# mysqladmin shutdown


Starting and shutting down replication threads from the server

[Email protected] ~]# mysqladmin Start-slave

[Email protected] ~]# mysqladmin Stop-slave


The other MySQL client tools also have

Mysqldump a Backup tool

Mysqlimport an import Tool

Mysqlcheck Inspection Tools









This article is from the "11097124" blog, please be sure to keep this source http://11107124.blog.51cto.com/11097124/1896942

MySQL basic commands and the use of MYSQLADMIN commands

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.