`

mysql非常有用的几个命令

 
阅读更多

 

mysql> use test;
Database changed
mysql> select @@version;  
+-----------+
| @@version |
+-----------+
| 5.5.15    |
+-----------+
1 row in set (0.00 sec)

mysql> select @@sql_mode;
+----------------------------------------------------------------+
| @@sql_mode                                                     |
+----------------------------------------------------------------+
| STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+----------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> show column from mytable;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'column from mytable' at line 1
mysql> show columns from mytable;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| a     | int(11)  | NO   | PRI | NULL    |       |
| b     | char(18) | NO   |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
2 rows in set (0.01 sec)

mysql> use mysql;
Database changed
mysql> show index from db;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| db    |          0 | PRIMARY  |            1 | Host        | A         |        NULL |     NULL | NULL   |      | BTREE      |         |               |
| db    |          0 | PRIMARY  |            2 | Db          | A         |        NULL |     NULL | NULL   |      | BTREE      |         |               |
| db    |          0 | PRIMARY  |            3 | User        | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| db    |          1 | User     |            1 | User        | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
4 rows in set (0.00 sec)

mysql> show privilges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'privilges' at line 1
mysql> show create table user;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| Table | Create Table


                                                                                                                                       |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| user  | CREATE TABLE `user` (
  `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
  `User` char(16) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Password` char(41) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Reload_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Shutdown_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Process_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `File_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Show_db_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Super_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Repl_slave_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Repl_client_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_user_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Event_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_tablespace_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `ssl_type` enum('','ANY','X509','SPECIFIED') CHARACTER SET utf8 NOT NULL DEFAULT '',
  `ssl_cipher` blob NOT NULL,
  `x509_issuer` blob NOT NULL,
  `x509_subject` blob NOT NULL,
  `max_questions` int(11) unsigned NOT NULL DEFAULT '0',
  `max_updates` int(11) unsigned NOT NULL DEFAULT '0',
  `max_connections` int(11) unsigned NOT NULL DEFAULT '0',
  `max_user_connections` int(11) unsigned NOT NULL DEFAULT '0',
  `plugin` char(64) COLLATE utf8_bin DEFAULT '',
  `authentication_string` text COLLATE utf8_bin,
  PRIMARY KEY (`Host`,`User`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges' |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 row in set (0.00 sec)

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 |
| Proxy                   | Server Admin                          | To make proxy user possible                           |
| 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                                       |
| Create tablespace       | Server Admin                          | To create/alter/drop tablespaces                      |
| Update                  | Tables                                | To update existing rows                               |
| Usage                   | Server Admin                          | No privileges - allow connect only                    |
+-------------------------+---------------------------------------+-------------------------------------------------------+
31 rows in set (0.00 sec)

mysql>








































































































































































































分享到:
评论

相关推荐

    mysql数据库命令

    在本篇文章中,我们将详细介绍几个基本且重要的MySQL命令,帮助读者更好地理解和操作MySQL数据库。 ### MySQL数据库命令介绍 #### 1. `mysqld-nt-remove` 该命令用于移除MySQL服务。当您不再需要MySQL服务在系统...

    查看MySQL数据库的命令

    这两个命令都可以用来查看指定表的列信息,包括字段名、数据类型、是否为主键等。这对于理解表结构非常有帮助。 - **命令**: `SHOW COLUMNS FROM table_name;` 与`DESCRIBE`类似,这条命令也可以用来查看表的列...

    MySQL鲜为人知的几个特殊技巧

    在本文中,我们将探讨几个鲜为人知的MySQL特殊技巧,这些技巧可以帮助数据库管理员和开发人员更高效地管理和操作数据库。 首先,MySQL允许用户以XML格式查看查询结果。这对于需要将查询结果与其他应用程序集成的...

    一台电脑同时安装MySQL5.x版本和MySQL8.x版本

    - 使用命令行工具(如cmd或PowerShell),以管理员身份运行,然后用以下命令分别创建两个版本的MySQL服务: - 对于MySQL5.x:`mysqld --install MySQL5x --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.x\...

    MySQL_命令集--命令大全

    除了以上介绍的基础命令外,还有许多其他有用的MySQL命令: 1. **显示数据库列表**:使用`SHOW DATABASES`命令可以查看所有可用的数据库。 ```sql SHOW DATABASES; ``` 2. **选择数据库**:使用`USE`命令切换...

    msf攻击Mysql服务.docx

    首先,让我们了解MSF中与MySQL相关的几个主要插件: 1. **auxiliary/scanner/mysql/mysql_login**:此模块用于扫描内网中的MySQL服务器,尝试使用不同用户名和密码进行登录测试。这在确定潜在的弱凭证或未授权访问...

    MySQL 8.0 参考手册教程pdf

    在本教程中,我们将深入探讨几个关键知识点,包括如何使用mysql客户端,连接和断开与服务器的连接,以及创建和管理数据库。 首先,mysql客户端程序是与MySQL服务器进行交互的主要工具,它允许用户运行SQL查询并查看...

    mysql administrator v1.2.17

     几乎所有的任务都可以用命令提示符下的mysqladmin 和mysql命令来完成,但是MySQL Administrator再下列方面将是非常的有优点。   1. 它的图形化的用户界面为用户提供了非常直观的接口。   2. 它提供了较好的...

    mysql常用命令

    ### MySQL常用命令详解 #### 一、退出MySQL操作界面:`quit` ...通过以上几个命令的应用,我们可以更加高效地管理和维护数据库,同时确保数据的安全性和准确性。希望这些基本的MySQL命令能对您有所帮助!

    MYSQL常用命令

    ### MySQL常用命令详解 #### 一、启动与退出MySQL 1. **进入MySQL**:启动MySQL Command ...这些命令涵盖了数据库的基本操作,对于日常开发和维护工作非常有用。熟练掌握这些命令可以帮助您更高效地管理MySQL数据库。

    mysql 5.6 for mac

    在 MySQL 5.6 版本中,有以下几个关键知识点: 1. **InnoDB 存储引擎优化**:MySQL 5.6 对 InnoDB 引擎进行了大量改进,提升了事务处理性能。其中包括更快的行锁定机制、更高的并发性、以及对 InnoDB 的缓冲池进行...

    mysql 监控 Monitoring_MySQL mysql_en mysql

    以下是Nagios中几个常用的MySQL监控插件: - **NRPE(Nagios Remote Plugin Executor)**:NRPE允许远程主机执行本地插件,这对于跨服务器监控MySQL特别有用。 - **MySQL Nagios Plugins**:这些是专门为MySQL设计...

    c语言操作mysql.pdf

    文档中提到了几个关键的函数和过程,包括mysql_init, mysql_real_connect以及mysql_query等。下面我们详细地解析这些知识点。 首先,文档中提到了mysql_init函数,它用于初始化一个MYSQL结构体,该结构体是后续所有...

    PHP+MYSQL数据库编程资料

    总的来说,PHP与MySQL的结合使用涉及到以下几个核心知识点: 1. MySQL数据类型的理解和选用,以适应不同的数据存储需求。 2. 掌握MySQL的基本命令,如创建/删除数据库、操作表及记录,便于数据库管理和维护。 3. ...

    Mysql游标(循环操作)

    游标的使用通常包括以下几个步骤: 1. **声明游标**:首先需要声明一个游标,并指定该游标将使用的SQL语句。 2. **打开游标**:使用`OPEN`命令来打开游标,使它准备好读取数据。 3. **获取数据**:通过`FETCH`命令...

    忘记mysql密码怎么办

    在使用MySQL数据库的过程中,有时可能会遇到不小心忘记MySQL root用户密码的情况。这无疑会给数据库管理和操作带来困扰,但不用担心,有几种方法可以帮助你...同时,了解这些应急恢复方法对于应对类似问题非常有用。

    mysql-5.5.62-winx64.zip

    安装MySQL 5.5.62-winx64通常包括以下几个步骤: 1. 下载并解压“mysql-5.5.62-winx64.zip”压缩包,这将提供所有必要的二进制文件和配置脚本。 2. 安装服务:通过执行“bin”目录下的“mysqld.exe”并指定相应的...

Global site tag (gtag.js) - Google Analytics