Home  >  Article  >  Database  >  马哥学习笔记五MYSQL初步

马哥学习笔记五MYSQL初步

WBOY
WBOYOriginal
2016-06-01 13:14:461091browse

1.mysql

-u USERNAME

-p

-h MYSQL_SERVER

linux:socket

windows:memory

2.交互式模式中的命令类别

客户端命令

服务器端命令

必须使用语句结束符,默认为封号

3.关系数据库对象:

索引

视图

约束

存储过程

存储函数

触发器

游标

用户

权限

事务

4.常用命令

DDL:数据库定义语言

create,alter,drop

DML:数据库管理语言

insert,update,delete

DCL:数据库控制语言

grant,revoke

创建数据库

create database db_name;

create database [if not exists] db_name;

删除数据库

drop database [if exists] db_name;

创建表

create table tb_name(col1,col2,...);

查看库中表:show tables from db_name;

查看表结构:desc tb_name;

删除表:drop table tb_name;

修改表:alter table tb_name

modify,change,add,drop

insert into tb_name(col1,col2,...) values|value ('string',num,...);

update tb_name set column=value where condition;

delete from tb_name where condition;

select 字段 from tb_name where condition

*:所有字段

where:没有条件表示显示所有行

创建用户:

create user 'username'@'host' identified by 'password';

drop user 'username'@'host';

grant pri1,pri2,...on db_name.tb_name to 'username'@'host' [identified by 'password'];

revoke pri1,pri2,... on db_name.tb_name from 'username'@'host';

查看用户的授权:show grants for 'username'@'host';

flush privileges;

为用户设定密码:

mysql>set password for 'username'@'host'=password('password');

# mysqladmin -uusername -hhost -p password 'password'

mysql>update user set password=password('password') where user='root' and host='127.0.0.1';

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn