电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 2217 人浏览分享

mysql的登陆和退出命令格式代码示例

[复制链接]
2217 0
本篇文章小编给大家分享一下mysql的登陆和退出命令格式代码示例 文章代码介绍的很详细小编觉得
挺不错的 现在分享给大家供大家参考,有需要的小伙伴们可以来看看。

mysql登陆的命令格式为:

1个
  1. mysql -h [hostip] -u [username] -p [password] [database]
复制代码

1.普通登陆mysql数据库

命令格式:mysql -u用户名-p密码,例如:mysql -u root -p root

如果在-p后没有提供密码,逐步在执行命令后要求用户输入密码

5f99367de3f7f.jpg

2.准备端口号登陆,mysql的默认端口号是3306,

命令格式:mysql -u用户名-p密码-P扩展号

即可 注意指定端口的字母P为大写,而标识密码的p为小写。

98.jpg

3.指定IP地址和端口号登录MySQL数据库

命令格式为:mysql -h ip -u用户-p -P扩展号

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

97.jpg

96.jpg

4.编制数据库登陆

mysql -h ip地址-u用户名-p密码数据库名

例如:mysql -h 127.0.0.1 -u root -p测试

查看当前登陆用户和数据库

38.jpg

1个
  1. 2
  2. select user();
  3.   select database();
复制代码

退出登陆命令

登陆进入mysql进入之后 可能到下面的提示信息,可以帮助看看输出结果
  1. mysql> help
  2. For information about MySQL products and services, visit:
  3.   http://www.mysql.com/
  4. For developer information, including the MySQL Reference Manual, visit:
  5.   http://dev.mysql.com/
  6. To buy MySQL Enterprise support, training, or other products, visit:
  7.   https://shop.mysql.com/
  8. List of all MySQL commands:
  9. Note that all text commands must be first on line and end with ';'
  10. ?     (\?) Synonym for `help'.
  11. clear   (\c) Clear the current input statement.
  12. connect  (\r) Reconnect to the server. Optional arguments are db and host.
  13. delimiter (\d) Set statement delimiter.
  14. edit   (\e) Edit command with $EDITOR.
  15. ego    (\G) Send command to mysql server, display result vertically.
  16. exit   (\q) Exit mysql. Same as quit.
  17. go    (\g) Send command to mysql server.
  18. help   (\h) Display this help.
  19. nopager  (\n) Disable pager, print to stdout.
  20. notee   (\t) Don't write into outfile.
  21. pager   (\P) Set PAGER [to_pager]. Print the query results via PAGER.
  22. print   (\p) Print current command.
  23. prompt  (\R) Change your mysql prompt.
  24. quit   (\q) Quit mysql.
  25. rehash  (\#) Rebuild completion hash.
  26. source  (\.) Execute an SQL script file. Takes a file name as an argument.
  27. status  (\s) Get status information from the server.
  28. system  (\!) Execute a system shell command.
  29. tee    (\T) Set outfile [to_outfile]. Append everything into given outfile.
  30. use    (\u) Use another database. Takes database name as argument.
  31. charset  (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
  32. warnings (\W) Show warnings after every statement.
  33. nowarning (\w) Don't show warnings after every statement.
  34. resetconnection(\x) Clean session context.
  35. For server side help, type 'help contents'
复制代码

通过输出信息 我们知道如下三条退出mysql的命令

1.退出

2.退出

3.问

您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

关注

0

粉丝

9021

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.