一、下载MySQL
可以去数据库的官网http://www.mysql.com进行MySQL下载
网盘链接:https://pan.baidu.com/s/1dvB4_gAqtOWcR7ovpAZzdQ
提取码:jqh4
二、安装MySQL
下载后,安装十分简单,一路点击next,并check你的root密码,MySQL就成功在你的电脑上安装完成了。目录如下:
三、启动数据库服务
启动命令 :net start mysql;
关闭命令: net stop mysql;
win+R键 打开运行命令cmd窗口,一定要是管理员下运行,不然会报:
C:\Program Files\MySQL\MySQL Server 5.5>net start mysql
发生系统错误 5。
拒绝访问。
在C:\Windows\System32 下找到cmd邮件使用管理员运行,打开mysql的bin目录下,输入net start mysql启动服务。
C:\Windows\system32>cd C:\Program Files\MySQL\MySQL Server 5.5
C:\Program Files\MySQL\MySQL Server 5.5>cd bin
C:\Program Files\MySQL\MySQL Server 5.5\bin>net start mysql
请求的服务已经启动。
请键入 NET HELPMSG 2182 以获得更多的帮助。
启动后进入mysql命令行:输入mysql -hlocalhost -uroot -p 密码是安装时设置的;
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -hlocalhost -uroot -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.5.29 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>
输入show databases; 语句后记得加分号“;”查看默认库:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql>
输入use test; 选择test库,输入show tables;显示test下所有表;
mysql> show tables;
ERROR 1046 (3D000): No database selected
mysql> use test
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql>
四、创建数据库表
这里使用个人推荐工具DBeaver,可连接多款数据库,不局限于navicat
网盘链接:https://pan.baidu.com/s/1fCPLTdOxg0KhNij56DvNIA
提取码:vq3l
安装完成,输入test数据库,root密码,测试链接成功
进入视图界面:
SQL编辑器,输入sql脚本:
CREATE TABLE test.t_user2 (
userName varchar(100) NULL,
password varchar(100) NULL
)
ENGINE=InnoDB
DEFAULT CHARSET=latin1
COLLATE=latin1_swedish_ci;
执行创建表成功,新增一条张三记录;