惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 冰封王座(.net)博客

实现qq的自动登录 - 冰封王座(.net)博客 - 博客园 创建带签名的cab包的完整流程 在C#中使用 makecert 创建自签名的证书 对比 javascript url编码 有关 java 与 C#细节不同 - 冰封王座(.net)博客 使用 DotnetOpenMail发送带附件的邮件 - 冰封王座(.net)博客 - 博客园 今天你处理异常了么? 防止SQL注入攻击 在DataGrid中进行值映射 - 冰封王座(.net)博客 - 博客园 UML视图使用 想要做个开源 大家谁有创意啊? 程序员每天该做的事 Google SiteMap的作用及协议格式详解[转摘] 取得客户端MAC Java学习之路:不走弯路,就是捷径 开发人员必备网站 Acess 存储与显示图片 css 外层保持固定高度的情况下 能随内层高度自适应变化 新的学习计划(10/8--10/15)
mysql常用命令
冰封王座(.net)博客 · 2007-02-03 · via 博客园 - 冰封王座(.net)博客
 

Mysql 命令

1. 登录数据库

mysql –h hostname –u username –p

enter password:******

2.         启动、停止数据库服务

net start mysql

net stop mysql

3.         创建用户

GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...]
    ON {tbl_name | * | *.* | db_name.*}
    TO user_name [IDENTIFIED BY 'password']
        [, user_name [IDENTIFIED BY 'password'] ...]
    [WITH GRANT OPTION]

Grant 权限列表 on 数据库名.表名 to 用户名@主机名 identified by 口令

实例(1):授权给用户user1 所有数据库的所有权限,并且可以在任何主机连接数据库grant all privileges on *.* to user1@”localhost” identified by ‘123456’

       Grant all privileges on *.* to user1@”%” identified by ‘123456’

实例(2):增加一个用户test2密码为abc,让他只可以在localhost上登录,并可以对数据库mydb进行查询、插入、修改、删除的操作(localhost指本地主机,即MYSQL数据库所在的那台主机),这样用户即使用知道test2的密码,他也无法从internet上直接访问数据库,只能通过MYSQL主机上的web页来访问了。

grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";

4.         修改密码

修改密码有两种方法

1) 直接修改数据库服务器中mysql数据库的表 user

如:use mysql

Update user set password=password(“admin”) where user=’root’ and host=’localhost’;

        Flush privileges;

注:flush 是清除缓存语句,

Flush PRIVILEGES mysql数据库授权表中重新装载权限。

2)        使用set password语句

Set password for root@localhost=password(‘123456’)

5.         创建数据库

1) 查看数据库

Show databases

2) 创建数据库

Drop database if exists studentinfo

Create database studentinfo

如果存在数据库studentinfo 则删除重新建立

6.         创建表

1) use studentinfo

drop table if exists student;

create table student(

        id int not null auto_increment,

        name varchar(20) not null default ‘name’,

        math int not null default 60,

        primary key (id));

)

Desc studentinfo 查看表结构

7.         插入操作

Insert into studentinfo values(1,’liying’,98);

Insert into studentinfo (id,name) values(1,’liying’);

可以从文件中导入数据

Load data infile ‘student.txt’ into table student

8.         查询、删除、修改操作

直接在 mysql>命令符下 运行sql语句即可

9.         修改表结构

1) 为表student增加一列english

Alter  table student add (English int not null default 60);

2) 修改name的数据类型

Alter  table student modify name varchar(30) not null

3) 修改english 的默认值

Alter table student alter English  set default 100

4) 删除english的默认值

Alter  table student alter English  drop default;