一、通过服务器连接
- 使用root账号连接mysql服务器;(输入密码时候密码不显示)
root@localhost:~$ mysql -u root -p
Enter password:
- 连接成功后会打印以下内容:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.6.40 Source distribution
Copyright (c) 2000, 2018, 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> 命令提示窗口,可以在上面执行任何 SQL 语句。
- 退出 mysql> 命令提示窗口可以使用 exit 命令,如下所示:
mysql> exit
Bye
二、通过Navicat软件连接
1、打开Navicat软件,点击连接;
2、填写连接名、主机名、用户名和密码后点击确定便可以连接到MySQL服务器;