MySQL学习笔记之一

MySQL装有一个名为mysql的命令行,在提示符下输入mysql将出现如下的简单提示:

➜  ~  mysql
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 135
Server version: 5.5.35-0ubuntu0.13.10.1 (Ubuntu)

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> 

mysql的命令行参数一般有:

-u 用户名

-p 密码

-h 主机名

-P 端口号

例如:mysql -u root -p -h localhost -P 3306

命令行会提示你输入密码

Enter password: 

也可以直接输入密码,mysql -p123456 或者mysql --password=123456

进入mysql后,SHOW DATABASES显示数据库信息,USE DATABASE进入数据库,SHOW TABLES显示table信息。

要显示某一table的列信息,SHOW COLUMNS FROM table或者DESCRIBE table。

其它的SHOW用法:

SHOW STATUS:显示服务器信息

SHOW GRANTS:显示用户的权限

SHOW ERRORS,SHOW WARNINGS,显示错误或警告信息。

原文地址:https://www.cnblogs.com/linxiyue/p/3536546.html