首页 技术 正文
技术 2022年11月19日
0 收藏 384 点赞 4,856 浏览 1535 个字

的说法啊打发

第1章 SQL语句

mysql版本:针对mysql-5.6.36 版本 (5.7会有一些变动)

1.1 常用命令

# 查看数据库

mysql> show databases;

show databases like ‘%pres%’;      #模糊查询

# 查看表

mysql> use xzy

mysql> show tables;

#查看权限

show grants for oldboy@’10.0.0.%’;

# 查看列

mysql> use xzy

mysql> desc test;

1.2 登录mysql

常见的特定于客户机的连接选项

-u <user_name>或–host=<user_name>

-p <password>

-h <host_name>或–host=<host_name>

–protocol=<protocol_name>

-P <port_number> 或–port=<port_number>

-S <socket_name> 或–socket=<socket_name>

1.2.1 修改密码

[root@db02 ~]# mysqladmin -uroot -p123 password 123456

[root@db02 ~]# mysql -uroot -p123456

mysql>

1.2.2 忘记密码-怎么办

#开启mysql  (跳过授权表)

#–skip-grant-tables 跳过授权表  –skip-networking禁止网络登录-即本地登录

/application/mysql/bin/mysqld_safe –skip-grant-tables  –skip-networking  &

#进入MySQL修改mysql.user表的内容

mysql        #直接登录(无需密码)

#修改mysql.user表内容

mysql> update mysql.user set password=PASSWORD(‘666666′)  where user=’root’ and host=’localhost’;

mysql> flush privileges;

#quit  退出即可用新密码666666登录

注意:5.7版本的不同

update mysql.user set authentication_string=PASSWORD(‘123456′)  where user=’sys’ and host=’localhost’

flush privileges;

1.3 授权grant

1.3.1 grant

格式

grant  权限   on  权限范围(对象)  to  用户  identified by  ”;

权限(角色):

select、update、delete、insert、drop、create

ALL

权限范围:

*.*  所有数据库对象

oldboy.*   oldboy单库下所有对象

oldboy.test  单表级别

用户:

repl@localhost

repl@’10.0.0.53′

repl@’10.0.0.%’

repl@’10.0.0.5%’

—–

要求:

1、用户只能通过10网段访问,用户名为oldboy,密码为123

2、只能对oldboy数据库下的对象进行增insert create、改update、查select

#创建

grant select,insert,update,create on oldboy.* to oldboy@’10.0.0.%’ identified by ‘123’;

#查看权限

show grants for oldboy@’10.0.0.%’;

#收回权限

revoke drop on oldboy.* from ‘oldboy’@’10.0.0.%’;

#删除用户

drop user oldboy@’10.0.0.%’

注意:

创建的权限信息,不在/data/下的数据库名目录下

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,085
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,560
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,409
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,182
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,819
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,902