mysql的登陆和退出命令格式

吾爱主题 阅读:101 2024-04-01 23:50:48 评论:0

mysql登陆的命令格式为:

?
1 mysql -h [hostip] -u [username] -p [ password ] [ database ]

1.普通登陆mysql数据库
命令格式:mysql -u 用户名 -p 密码,例如: mysql -u root -p root
如果在-p后没有提供密码,则会在执行命令后要求用户输入密码

2.制定端口号登陆,mysql的默认端口号是3306,
命令格式:mysql -u 用户名 -p 密码 -p 端口号
即可,注意指定端口的字母p为大写,而标识密码的p为小写。

3.指定ip地址和端口号登录mysql数据库
命令格式为:mysql -h ip -u 用户 -p -p 端口号
例如:mysql -h 127.0.0.1 -u root -p -p 3306


4.制定数据库登陆
mysql -h ip地址 -u 用户名 -p 密码 数据库名
例如:mysql -h 127.0.0.1 -u root -p test

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

?
1 2 select user ();    select database ();

退出登陆命令
登陆进入mysql进入之后,可能到下面的提示信息,可以help看看输出结果

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 mysql> help   for information about mysql products and services, visit:    http://www.mysql.com/ for developer information, including the mysql reference manual, visit:    http://dev.mysql.com/ to buy mysql enterprise support, training, or other products, visit:    https://shop.mysql.com/   list of all mysql commands: note that all text commands must be first on line and end with ';' ?     (\?) synonym for `help '. clear   (\c) clear the current input statement. connect  (\r) reconnect to the server. optional arguments are db and host. delimiter (\d) set statement delimiter. edit   (\e) edit command with $editor. ego    (\g) send command to mysql server, display result vertically. exit   (\q) exit mysql. same as quit. go    (\g) send command to mysql server. help   (\h) display this help. nopager  (\n) disable pager, print to stdout. notee   (\t) don' t write into outfile. pager   (\p) set pager [to_pager]. print the query results via pager. print   (\p) print current command. prompt  (\r) change your mysql prompt. quit   (\q) quit mysql. rehash  (\#) rebuild completion hash. source  (\.) execute an sql script file. takes a file name as an argument. status  (\s) get status information from the server. system  (\!) execute a system shell command. tee    (\t) set outfile [to_outfile]. append everything into given outfile. use    (\u) use another database . takes database name as argument. charset  (\c) switch to another charset. might be needed for processing binlog with multi-byte charsets. warnings (\w) show warnings after every statement. nowarning (\w) don 't show warnings after every statement. resetconnection(\x) clean session context.   for server side help, type ' help contents'

通过输出信息,我们知道如下三条退出mysql的命令
1. exit
2. quit
3. \q

到此这篇关于mysql的登陆和退出命令格式的文章就介绍到这了,更多相关mysql登陆和退出内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://blog.csdn.net/qq_36744627/article/details/81144005

可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

【腾讯云】云服务器产品特惠热卖中
搜索
标签列表
    关注我们

    了解等多精彩内容