Database installation, and configuration files

Database Concepts

That Mysql capable Mani? When it is a piece of software installed on any computer or server, as long as I tell it to create a file, add data, delete data it can help me to do the desired operation

We can not understand that for the time being as mysql is used to help us manipulate files!

MySQL: a software for managing files (two programs)

- server software

-socket server

- Local file operations

- Analysis of Instruction

- Client Software

-socket client

- Send command

- Analysis of Instruction

The client can have many, python, java, php, c ++ programming can be a client, specify the ip port link server can be operated in code

So the question is, different clients I train a server, the same can not be achieved without language exchange. So we should have a common language for the job >>> parsing command (sql statement)

 

skill:

- installation services and client

-link

- Learn sql statement rule, specify the server to do anything

 

mysql is just a way to help us manage data, software, and other similar software is to help you manage the database by sending instructions

Other similar software:

Relational databases: sqlite, db2, oracle, access, sql server, MySQl

Non-relational databases: mongodb, redis

Relational: There are constraints between each other or linked

 

Summary: mysql is to help us do the corresponding operations on remote files

In the official website to download step

1

2

3

 

4

5

MySQL Installation

mysqld server

mysql client

 

Software Directory Structure acquaintance

 

Terminal best to run as administrator

 

Switch to start the mysqld server mysql directory (blocking, listening address, fixed ip and port)

cd D:\mysql56
D:

Cmd to open a new window to start the mysql client

 

Links mysql:

mysql -h 127.0.0.1 -P 3306 -uroot -p password is lost, directly enter

If it is in the machine landed mysqld server, you can be abbreviated as mysql -uroot -p

Client Server request process analysis

show databases interpretation of the concept of folders and libraries

 

Link variable configuration

 

系统服务制作(制作之前一定要先把mysql关闭)

# 查看mysqld进程
tasklist |findstr mysqld
# 杀死mysqld进程
taskkill /F /PID 'PID号'

将mysqld这款软件做成系统服务软件

mysqld --install

查看计算机当前运行程序数

services.msc

修改密码与破解管理员密码

mysqladmin -uroot -p password "123"

# 第一次修改完密码以后,之后还修改密码需要
mysqladmin -uroot -p123 password "123456"
# 为了后续调试方便,这里把密码设为空值
mysqladmin -uroot -p123 password "新密码"

破解密码

  • 先关闭mysqld服务端

  • 以跳过授权表的方式在命令行中启动mysqld服务端

    mysqld --skip-grant-tables
  • 客户端直接以无密码的方式登陆root用户修改密码

    mysql -uroot -p
  • 修改管理员密码

    update mysql.user set password=password("123") where user="root" and host="localhost";
    flush privileges;  # 刷新权限
  • 命令行杀死mysqld服务

    tasklist |findstr mysqld
    taskkill \F \PID 'PID'
  • 服务管理正常启动mysqld

 

统一字符编码

mysql命令:"\s" 查看编码

修改配置文件,执行时会自动查找my.ini文件

mysql不输用户名和密码,会默认以游客模式登陆,不好!

# my.ini配置文件特点
[mysql]
#终端输入mysql打头的命令就会加载下面的配置
username='root'  # 演示确实加载改文件,但是username叫user才正确
password = '123'
[mysqld]

通用配置

[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

mac系统

finder中切换到默认安装路径下/usr/local/mysql

下面就是一大堆文件目录

配置文件是my.cnf,没有int等windows上的配置文件

 

 

 

基本sql语句

对数据的增删改查

sql书写错误,只要没加分号,可以加\c使前面的sql语句失效

  • 针对文件夹的(库)

    # 增
    create database db1 charset utf8;
    # 改
    alter database db1 charset gbk;
    # 查
    show databases;
    show create database db1;
    # 删
    drop database db1;
  • 针对文件的(表)

    文件首先需要在文件夹下面,所以在操作文件之前,应该先确定操作的是哪个文件夹下面的文件

    # 切换文件夹
    user db1;
    select database();  # 查看当前所在的库
    # 增
    create table t1(id int,name char);  # 创建出来的可能是多个文件,解耦管理
    # 改
    alter table t1 modify name char(16);
    # 查
    show tables;
    show create table t1; # 查看表的详细信息
    describe t1; == desc t1;  # 查看表结构
    # 删
    drop table t1;
  • 针对(记录)

    # 增
    insert into db1.t1 values (1,'egon'),(2,'kevin'),(3,'jason');  # into可加可不加,db1可以不指定,默认就是在当前库下
    # 改
    update db1.t1 set name='DSB' where id > 1;
    update db1.t1 set name='DSB' where id = 2 or id = 3;
    # 查
    select id,name from db1.t1;  # db1可不指定,默认当前库下
    select * from t1;
    # 删
    delete from db1.t1 where id >3;
    delete from db1.t1 where name='egon'  # 这里注意如果少了一个引号,后面无论敲什么都没有用了需要将引号补全

库相关操作参考egon博客即可

表操作

存储引擎

文件格式有很多种,对应的软件也有很多种txt,pdf等

针对不同类型的文件,需要对应有不同的软件帮助我们去操作

# 查看所有的存储引擎
show engines;

# 查看不同存储引擎存储表结构文件特点
create table t1(id int)engine=innodb;
create table t2(id int)engine=myisam;
create table t3(id int)engine=blackhole;
create table t4(id int)engine=memory;

insert into t1 values(1);
insert into t2 values(1);
insert into t3 values(1);
insert into t4 values(1);

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/cherish937426/p/11366494.html