Home > Database > Mysql Tutorial > body text

如何用cmd连接Mysql数据库_MySQL

WBOY
Release: 2016-06-01 13:24:00
Original
1281 people have browsed it

bitsCN.com

通常我们在网络上看到的mysql教程和mysql工具书,里面都是cmd命令和结果集。
也许有一些初学者不懂在系统的哪个角落输入这些命令,或者启动mysql的一些工具,下面教你怎样进入这个mysql的cmd模式和基本的mysql的cmd操作。
以window系统为例,首先,我们把鼠标移动到左下角的开始,点击【开始】按钮,找到【运行】,打开运行后,在输入框里面输入“cmd”,然后按回车键(也就是enter键),随即进入了cmd模式(一个背景为黑色的窗口,里面有一些英文字母)。
打开cmd后,我们看到:C:/Ducuments and Settings/Administrator>  (有一些朋友的系统使用的不是Administrator系统用户的也就不同了,如果你进入window系统使用的用户为user,那这个Administrator就换为user)
其实这串英文字母表示的是一个系统的位置,现在进入cmd之后的位置为:c盘的Ducuments and Settings目录里面的Administrator目录下,那么,既然知道这个cmd的位置的意思了,我们接着要做什么呢?对了,就是要进入mysql的bin目录,到里面才可以用cmd启动mysql。
以mysql5.0为例,mysql的安装目录在c盘的Program Files目录里面的MySQL里面的MySQL Server 5.0(也就是C:/Program Files/MySQL/MySQL Server 5.0),那么,我们就准备要进入这个目录里面了。
步骤如下:
C:/Ducuments and Settings/Administrator> cd/(回车键)
出现下面:
C:/>
第二步:
C:/>cd C:/Program Files/MySQL/MySQL Server 5.0/bin(回车键)
出现:C:/Program Files/MySQL/MySQL Server 5.0/bin>
第三步:(连接mysql服务器)
C:/Program Files/MySQL/MySQL Server 5.0/bin>mysql -hlocalhost -uroot -p(回车键)
(上面的-hlocalhost是指使用本地用户来连接,-uroot是指使用用户名为root的用户来连接,-p是指空密码,一般初学者都还没有设置root的用户密码的,如果你在安装mysql5.0时候配置了服务器后,第一个要您设置root的密码,请你记住,把它填入上面的-p之后)
成功连接后,就会出现mysql的欢迎语和mysql的版本号,
接着cmd的盘符出现为:
mysql>
那就表示成功连接mysql服务器了,以后看到工具书里面的命令,为mysql>命令,你就在这里输入行了,结果集会出现在cmd里面。

bitsCN.com
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!