做网站 哪些公司,番禺24小时核酸检测,做网站如何可以实现窗口切换功能,模板建站难吗文章目录1、连接命令2、断开连接3、命令结束符4、查看所有数据库5、切换到指定数据库6、查看当前使用的数据库7、查看库中所有表8、查看所有用户9、执行SQL脚本10、查询当前时间1、连接命令
首先定位到MySQL安装根目录/bin目录下#xff0c;然后执行如下命令#xff1a;
my…
文章目录1、连接命令2、断开连接3、命令结束符4、查看所有数据库5、切换到指定数据库6、查看当前使用的数据库7、查看库中所有表8、查看所有用户9、执行SQL脚本10、查询当前时间1、连接命令
首先定位到MySQL安装根目录/bin目录下然后执行如下命令
mysql -h[主机名] -P[端口] -u[用户名] -p[密码]#例如
mysql -hlocalhost -P3306 -uroot -p123注 localhost是指MySQL数据库安装在本机如果是远程机器那么localhost换成对应机器的IP地址即可 端口默认为3306的话可以不输入-P 最好不要在一行中输入密码这样敲出去会被别人看到。
如果不想被看到密码可以使用如下方式连接
mysql -hlocalhost -uroot -p回车之后提示输入密码
Enter password:不过这回你输入的密码不会被显示出来心怀不轨的人也就看不到了输入完成点击回车就成功连接到了服务器。
执行成功之后的界面如下
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.7.30 MySQL Community Server (GPL)Copyright (c) 2000, 2020, 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 是一个客户端的提示符之后客户端发送给服务器的命令都需要写在这个提示符后边。
注如果你愿意你可以多打开几个命令行窗口每个窗口都可以使用连接命令从而达到运行多个客户端程序的效果每个客户端程序都是互不影响的。 2、断开连接
quit
exit
\q注如上三个命令是关闭客户端程序的方式不是关闭服务器程序的方式。 3、命令结束符
在书写完一个命令之后需要以下边这几个符号之一结尾
;
\g
\G4、查看所有数据库
show databases;查询结果
--------------------
| Database |
--------------------
| information_schema |
| db_cwtsb |
| mysql |
| performance_schema |
| sys |
--------------------
5 rows in set (0.00 sec)5、切换到指定数据库
use [数据库名称];这里我们选择 information_schema
use information_schema;查询结果
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed6、查看当前使用的数据库
select database();查询结果
--------------------
| database() |
--------------------
| information_schema |
--------------------
1 row in set (0.00 sec)7、查看库中所有表
show tables;查询结果
---------------------------------------
| Tables_in_information_schema |
---------------------------------------
| CHARACTER_SETS |
| COLLATIONS |
...
| INNODB_SYS_TABLESTATS |
---------------------------------------
61 rows in set (0.00 sec)8、查看所有用户
select user,host,authentication_string FROM mysql.user;查询结果
---------------------------------------------------------------------
| user | host | authentication_string |
---------------------------------------------------------------------
| root | localhost | *112646FC4B3886349C1C2A17DDFD146AD53C1B1 |
| mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHER |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHER |
---------------------------------------------------------------------
3 rows in set (0.01 sec)9、执行SQL脚本
source [脚本.sql文件]10、查询当前时间
select now();查询结果
---------------------
| now() |
---------------------
| 2022-03-07 11:59:16 |
---------------------
1 row in set (0.00 sec)