Syntax MySQL database concepts

Database Concepts

Save the data part, saved to a public place, all user data related to the relevant public must be the place to find

MySQL

Is essentially a web-based application communications software based on any underlying network communication is socket

MySQL can be seen as a software support remote file operations

Library folder >>>

Table >>> file

>>> record data in a file line by line, called a section of the recording

Header: is the first row of the table

Fields: Field Name Field Type +

Mysqld server

Socket-based communication

Send and receive information

SQL statement (a common standard)

Mysql client

Socket-based communication

Send and receive information

SQL statements

ps: MySQL not only supports MySQL client operating, but also support other programming languages ​​directly manipulate python, java, c ++, php syntax is not the same

DBMS: Database Management System

Relational databases: there may be associated with the data between the data and restrictions, a relational database table structure are usually, the first step is determined by the relational database table structure

ps:MySQL,oracle,sqlite,db2,sql,server

Non-relational databases: usually a K, of the stored key-value data V

ps: redis, mongodb (document database, very close to non-relational data relational), memcache

grammar

Server mysqld

Client mysql

sql statement is the end of the good points, good points does not knock you did not finish entering default, the client will let you continue typing

Client login MySQL-uroot--h 127.0.0.1 -p 3306 -p / MySQL-uroot--p

Client exit exit; / quit;

Mysqld will be made into a system service mysqld --install

View a process tasklist | findstr name

Kill the process  taskkill / F / PID process ID

change Password:

1. No password is case mysqladmin -uroot -p password new password

2. password case mysqld -uroot -p password old password new password

decryption:

First started in the server stopped

1. Skip username and password authentication (authorization table) to start the server mysqld --skip-grant-tables

2. Modify the password corresponding to the administrator user updata mysql.user set password = password (new password) where user = 'root' and host = 'localhost';

3. Close the current server to verify the user's password to re-start the way

4. In the normal manner username and password server connected mysql

View mysql server simple configuration \ s

Profiles:

mysql configuration file that comes with not modified, but they can create a configuration file my.ini

mysql server startup will automatically load the configuration within your my.ini configuration file

You need to first stop after you modify the server configuration file restart to take effect

 

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

[client]
default-character-set=utf8

[mysql]
user='root'
password=密码
default-character-set=utf8

 

数据的基本操作语法

库(类似文件夹)

create database 文件名;

show databases; 查所有库

show create database 库名; 查指定的库

alter database 库名 charset='gbk'; 修改编码

drop database 库名; 删库(慎用!!!!!!!)

在创建表的时候,需要先指定库(文件创建在文件夹内)

指定库 use 库名

查看当前所在库 select database();

create table 表名(字段名 字段类型,字段名 字段类型);

show tables; 查看所在库中的所有表

show create table 表名; 指定表查看

desc 表名 <==> describe 表名; 指定查看表中的内容

alter table 表名 modify 字段 字段类型;

drop table 表名;

记录(数据)

先创建一个库或者指定一个已存在的库,切换到该库下,创建表,在操作记录

create database 库名;

create table 表名(字段 字段类型);

insert into 表名 values(对应字段的内容); 插入单挑数据

insert into 表名 values(对应字段的内容1),(对应字段的内容2),...; 插入多条数据

select * from 表名; 查询指定表中的所有字段信息

select 字段 from 表名; 查询指定表中的指定字段信息

select 字段1,字段2 from 表名 where 字段1=信息 or 字段2=信息; 带有筛选条件的字段信息

update 表名 set 字段=新信息 where 字段=信息; 修改数据的一个字段信息

update 表名 set 字段=新信息,字段=新信息 where 字段=信息; 修改数据的多个字段

delete from 表名 where id=1; 指定删复符合条件的数据

delete from 表名; 删除表中的全部数据

Guess you like

Origin www.cnblogs.com/waller/p/11365887.html