使用命令连接
打开终端,运行命令
mysql -uroot -p
回车后输入密码
连接成功后如下
(h2) dy@ding:~$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.30-0ubuntu0.16.04.1 (Ubuntu)
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>
- 登录成功后,输入如下命令查看版本号
select version();
- 显示当前时间
select now();
- quit或exit退出
远程连接
mysql -hip地址 -uroot -p
本文详细介绍如何通过命令行方式连接MySQL数据库,包括本地和远程连接的方法,以及连接后的基本操作,如查看数据库版本和当前时间。此外,还提供了退出数据库的命令。
1970

被折叠的 条评论
为什么被折叠?



