使用命令连接
打开终端,运行命令
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