MySQL笔记
MySQL官网
卸载
1、 停止mysql服务
2、 卸载mysql软件,可以通过控制面板
3、 数据文件备份再删除(也可以不删)
4、 环境变量删除
5、 5.7版本需要手动清理管理里面的mysql服务,清理注册表,8.0不需要手动清理。
6、 重启电脑
7、关于安装卸载会出现很多问题,可以在csdn上查找解决方法
启动mysql服务
cmd
mysql --version
mysql -uroot -p123456 -hlocalhost -p3306 端口号3306
mysql -uroot -p123456 -hlocalhost -P13306 端口号13306 自己设置的5.7版本的端口号为13306,不能与8.0的重复
-h是写ip的,本机就写localhost
-P端口号
查看版本指令 select version();
在cmd里开启关闭服务
net start/stop mysql80
net start/stop mysql57
netstat -ano 查看mysql的端口号和进程id(pid)
-
-u 用户
-
-p 密码
-
-h 主机
-
-P 端口
基本命令
show databases; 显示数据库命令 (;分号结尾)
create database dbtest1; 创建数据库命令
use dbtest1; 使用dbtest1数据库
create table employees(id int,name varchar(15)); 创建表格,15表示长度
show tables; 显示表格
select * from employees; 显示employees表里的所有数据
insert into employees values(1001.'tom'); 插入数据命令
show variables like 'character_%'; 查看关于字符变量的编码格式
show variables like 'collation_%'; 查看字符排列校验
drop database dbtest1; 删除数据库
drop table tbtest2; 删除表
show create database dbtest1; 查看数据库的详细信息
show create table tbtest1; 查看表的详细信息
alter table studentcharset utf8; 修改表的字符编码为utf8
alter database dbtest1 charset utf8; 修改数据库的字符编码为utf8
非关系型数据库的类型
-
键值型数据库:Redis
-
文档型数据库:MongoDB
-
搜索引擎数据库:ES、Solr
-
列式数据库:HBase
-
图形数据库:infoGrid
MySQL图形化管理工具
-
MySQL Workbench
-
Navicat
-
SQLyog
-
dbeaver
MySQL5.7修改配置文件
-
默认的数据库使用的字符集是latin1,我们需要修改为:utf8
-
修改信息,修改my.ini文件
no-beep default-character-set=utf8 (修改位置) # default-character-set= # SERVER SECTION # ---------------------------------------------------------------------- # # The following options will be read by the MySQL Server. Make sure that # you have installed the server correctly (see above) so it reads this # file. # # server_type=3 [mysqld] character-set-server=utf8 (修改位置) collation-server=utf8_general_ci (修改位置) # The next three options are mutually exclusive to SERVER_PORT below. # skip-networking # enable-named-pipe # shared-memory
-
修改完需要重启服务