通常,我们要把数据库理解为“你用,还是不用,它就在那里!”
1.1. 开启/关闭数据库服务
1.1.1. 通过系统服务
1.1.2. 通过命令行方式
在管理员模式下运行cmd,执行如下命令:
Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。
尝试新的跨平台 PowerShell https://aka.ms/pscore6
PS C:\Users\myxc> net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
PS C:\Users\myxc> net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
PS C:\Users\myxc>
PS C:\Users\myxc>
1.2. 客户端连接数据库服务器
数据库就在那里!连,还是不连,就看你了!任何连接或访问数据库的“软件/工具”,都可以称为“客户端”。
1.2.1. 命令行连接数据库
连接(进入)数据库命令:mysql -h主机地址 -u用户名 -p (以管理员身份开启windows CMD命令行)
PS C:\Users\myxc> mysql -hlocalhost -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2012, 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>
链接数据库成功如上面代码所示。
特别注意:cmd中登录后,请立即使用 "set names gbk;
" 语句来设定连接编码。
set names gbk; # Query OK, 0 rows affected (0.00 sec)
表示当前连接到数据库的“客户端”的字符编码是gbk(固定的,不可更改)。
退出数据库命令:
# 退出Mysql的三种方式
quit;
exit;
\q;
1.2.2. navicat软件连接数据库
1.2.3. phpmyadmin“网站”连接数据库
安装(配置)该站点:
- hosts文件中设定域名解析: www.myadmin69.com
- 拷贝网站文件到指定目录: bj-php-69/myadmin/
- httpd-vhost.conf文件中设定站点。