Mysql的使用
1、先确保mysql服务是开启的
因为mysql是TCP/IP协议的网络应用程序,所以必须先开启服务器,客户端才能连接。
【计算机】–>右键–>【管理】–>【服务】–>找到服务名,启动
2、使用客户端进行连接
客户端的种类很多:
(1)自带客户端
“开始菜单”–>MySQL–>MySQL Server 5.5 --> MySQL 5.5 Command Line Client
缺点:只能使用root用户登录
(2)普通的命令行客户端
命令格式:
mysql -h服务器IP地址 -P端口号 -u用户名 -p回车
EnterPassword:
例如:
C:\Windows\System32>mysql -hlocalhost -P3306 -uroot -p
Enter password:123456
说明:-h与localhost,-P与3306,-u与root之间可以有空格也可以没有
但是-p回车之间不要加空格
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.27 MySQL Community Server (GPL)
Copyright © 2000, 2015, 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>
(3)可视化客户端
例如:sqlyog,navicat等
(4)Java等程序连接数据库,也属于客户端
凡是客户端连接服务器,都需要指定:
(1)IP地址(2)端口号(3)用户名(4)密码(5)连接哪个数据库(如果是代码,那么需要说是哪个数据库)