Linux基礎命令---mysql

一生有你llx發表於2019-07-02

mysql

mysql 是一個簡單的sql shell,它可以用來管理mysql資料庫。

此命令的適用範圍:RedHat、RHEL、Ubuntu、CentOS、Fedora。

 

1 、語法

mysql [options]  db 

 

2 、引數列表

選項

說明

- ? | --help

顯示幫助資訊

--auto-rehash

啟用自動rehash功能

--bind-address = ip

繫結ip,當電腦有多個網路卡的時候,可以指定mysql連線時的網路卡

--character-sets-dir  =  path

指定字符集所在的目錄

--column-names

在結果中顯示列名

-C | --comments

在傳送給伺服器的狀態中顯示註釋

-c | --compress

在伺服器和客戶端之間的資料進行壓縮

-D   db  |  --database = db

指定資料庫名

--default-character-set = chatset

預設的字符集

-e   statement  |  --execute = statement

指定要使用的指令

-f | --force

強制執行

-H | --html

輸出html格式

-i | --ignore-spaces

忽略空格

--line-numbers

為錯誤資訊顯示行號

--local-infile=0|1

關閉或者開啟LOAD DATA INFILE功能

-A | --no-autp-rehash

關閉自動rehash功能

-b | --no-beep

關閉出錯提醒

-p   password  |  --password =

連線資料庫使用的密碼

-W | --pipe

使用有名管道連線資料庫

-P   port  |  --port =

連線資料庫使用的埠

-- protocol = TCP|SOCKET|PIPI|MEMORY

連線資料庫使用的協議

-q | --quick

不快取查詢結果

-s | --silent

輸出簡短的內容

-v | --verbose

顯示詳細執行過程

-V | --version

顯示版本資訊

-w | --wait

等待時間

-X | --xml

產生xml輸出

-u   user  |  --user =

連線資料庫的使用者名稱,預設是rootq

 

3 、例項

1 )登入

[root@localhost ~]#  mysql -u root –p             // 使用使用者 root 連線資料庫

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.1.71 Source distribution

 

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql> quit           // 退出

Bye

2 )檢視許可權

mysql>  show privileges;

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

| Privilege               | Context                               | Comment                                              |

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

| Alter                   | Tables                                | To alter the table                                    |

| Alter routine           | Functions,Procedures                  | To alter or drop stored functions/procedures          |

| Create                  | Databases,Tables,Indexes              | To create new databases and tables                    |

| Create routine          | Databases                             | To use CREATE FUNCTION/PROCEDURE                      |

| Create temporary tables | Databases                             | To use CREATE TEMPORARY TABLE                         |

| Create view             | Tables                                | To create new views                                   |

| Create user             | Server Admin                          | To create new users                                   |

| Delete                  | Tables                                | To delete existing rows                               |

| Drop                    | Databases,Tables                      | To drop databases, tables, and views                  |

| Event                   | Server Admin                          | To create, alter, drop and execute events             |

| Execute                 | Functions,Procedures                  | To execute stored routines                            |

| File                    | File access on server                 | To read and write files on the server                 |

| Grant option            | Databases,Tables,Functions,Procedures | To give to other users those privileges you possess   |

| Index                   | Tables                                | To create or drop indexes                             |

| Insert                  | Tables                                | To insert data into tables                            |

| Lock tables             | Databases                             | To use LOCK TABLES (together with SELECT privilege)   |

| Process                 | Server Admin                          | To view the plain text of currently executing queries |

| References              | Databases,Tables                      | To have references on tables                          |

| Reload                  | Server Admin                          | To reload or refresh tables, logs and privileges      |

| Replication client      | Server Admin                          | To ask where the slave or master servers are          |

| Replication slave       | Server Admin                          | To read binary log events from the master             |

| Select                  | Tables                                | To retrieve rows from table                           |

| Show databases          | Server Admin                          | To see all databases with SHOW DATABASES              |

| Show view               | Tables                                | To see views with SHOW CREATE VIEW                    |

| Shutdown                | Server Admin                          | To shut down the server                               |

| Super                   | Server Admin                          | To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.   |

| Trigger                 | Tables                                | To use triggers                                       |

| Update                  | Tables                                | To update existing rows                               |

| Usage                   | Server Admin                          | No privileges - allow connect only                    |

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

29 rows in set (0.00 sec)

 

 

     

      做了一個Linux學習的平臺,目前出來一個雛形,各位可以參考使用

      連結:https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ  密碼:n7bk 

     


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29270124/viewspace-2644013/,如需轉載,請註明出處,否則將追究法律責任。

相關文章