First, what is the database
Database: system management data. The warehouse is used to store data
Object essence of management is to file
Second, the composition of the database
Library: storing multiple tables (folder)
Table: contains a plurality of records of the same structure (file)
Record : contains one of data (binary data) a plurality of key-key-value pairs
Field: information itself == key-value (binary data)
Third, the classification database
Relational Database:
- The concept of table
- To record a table storing data
mysql oracle sqlServer access db2
Non-relational databases
- No concept of table
- Data stored by the key-value key
mongodb redis memcache
Fourth, the uninstall database
"""
前提)启动终端,输入 mysql,如果不是提示 不是内部或外部命令,代表已安装数据库
1)直接连入
i 搜索:服务,检索mysql服务,有
停止服务,并移除服务 - 启动管理员终端:mysqld --remove
ii 搜索:服务,检索mysql服务,无 (mysql使用命令启动)
停止服务,启动管理员终端
tasklist | findstr mysql
taskkill /pid 进程pid /f
2)连接超时
搜索:服务,检索mysql服务,移除服务即可
3)移除环境变量
总结:如果能连入,先停止服务 | 如果添加了服务,就移除服务 | 取消环境变量配置
"""
Fifth, the installation of the database
- Extracting free installation version (5.6 - no initial password)
- Configuration environment variable: bin under the absolute path to the database
- Configure the service:
Start administrator terminal: mysqld --install [nmysql]
Sixth, database startup
# 前提:配置环境变量
# 了解
# 1.前往数据库安装路径,bin文件夹下,cmd执行 mysqld 启动mysql服务器端
# 2.前往数据库安装路径,bin文件夹下,cmd执行 mysql 启动mysql客户端连接服务器端
Seven, the database connection
1)游客登陆(不一定能登入,登入了也啥都不能干)
>: mysql
2)账号密码登录
>: mysql -u root -p
再输入密码,没有任何提示,没有密码直接回车
3)连接指定服务器的mysql
>: mysql -hIP地址 -P端口号 -u账号 -p
回车后敲入密码
eg:
>: mysql -hlocalhost -P3306 -uroot -p
4)退出数据库
>: quit
>: exit
Eight, database configuration
# 通过配置文件统一配置的目的:统一管理 服务端(mysqld) 、客户端(client)
# 配置了 mysqld(服务端) 的编码为utf8,那么再创建的数据库,默认编码都采用utf8
# 配置流程
# 1)在mysql安装根目录下,创建配置文件:my.ini
# mac下配置文件名叫 my.cnf
# 2.设置配置信息并保存(统一字符编码,设置数据库模式 5.7以上版本吗,默认安全模式)
[mysqld] # 服务器配置
port=3306 # 可以修改数据库默认端口(如果数据库端口被其他软件占用)
# 统一字符编码
character-set-server=utf8 # 编码格式
collation-server=utf8_general_ci # 排序方式(默认跟编码格式走)
# 设置安全模式
sql_mode=strict_trans_tables
# 设置非安全模式
# sql_mode=no_engine_substitution
[client] # 客户端都叫[client]
default-character-set=utf8 # 编码格式
# user = 账号
# password = 密码
# 3)重启数据库服务