mysql 数据库的常用命令
system命令
在mysql命令符下,可以执行sql命令:
mysql -u root -p --socket=/home/vpnmysql/mysql/mysql.sock -D testdb3
mysql>
在mysql命令符下有时候突然想执行下shell的命令,比如查看当前路径有那些文件,就可以使用system命令了,相当于从mysql命令符临时切换到了操作系统了,可以执行shell命令了,个人感觉这个命令挺有用的~
mysql> system shell command
mysql> system ls;
test1.sh
help contents 命令
如果新手刚接触mysql,一个命令也不知道,mysql也提供方法可以查看的:
mysql> mysql testcc;#testcc是个不存在的错误命令
Nothing found
Please try to run 'help contents' for a list of all accessible topics
输入错误的命令,提示找不到,并且告诉可以使用'help contents'命令
mysql> help contents;
You asked for help about help category: "Contents"
For more information, type 'help <item>', where <item> is one of the following
categories:
Account Management
Administration
Compound Statements
Data Definition
Data Manipulation
Data Types
Functions
Functions and Modifiers for Use with GROUP BY
Geographic Features
Help Metadata
Language Structure
Plugins
Procedures
Storage Engines
Table Maintenance
Transactions
User-Defined Functions
Utility
mysql全部命令的总目录都列出来了,想学习命令都可以通过这个目录进一步查看和学习了,比如账号管理方面的
mysql> help Account Management
You asked for help about help category: "Account Management"
For more information, type 'help <item>', where <item> is one of the following
topics:
ALTER USER
CREATE USER
DROP USER
GRANT
RENAME USER
REVOKE
SET PASSWORD
列出这个目录下的全部命令,现在想查看哪个命令,继续查看帮助就可以了,如下
mysql> help ALTER USER;
Name: 'ALTER USER'
Description:
Syntax:
ALTER USER user_specification
[, user_specification] ...
user_specification:
user PASSWORD EXPIRE
The ALTER USER statement alters MySQL accounts. To use it, you must
have the global CREATE USER privilege or the INSERT privilege for the
mysql database. This statement was added in MySQL 5.6.6.
For each account, ALTER USER expires its password. For example:
ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE;
The account name uses the format described in
http://dev.mysql.com/doc/refman/5.6/en/account-names.html. If you
specify only the user name part of the account name, a host name part
of '%' is used.
。。。。。。。
ALTER USER的使用方法和具体例子都列出来了,不管新手还是老手,这都是一个好方法,再好的记忆力,有时候也会忘的,知道了这个方法,随时可以查看了。