设为首页 加入收藏

TOP

Linux下MySQL 5.6.24的编译安装与部署(三)
2015-08-31 19:59:21 来源: 作者: 【 】 浏览:68
Tags:Linux MySQL 5.6.24 编译 安装 部署
tified by 'pw123';


mysql> grant all on mydb.* to admin1@'localhost' identified by '123456';


mysql> grant select on mydb.* to admin2@'192.168.0.0/24' identified by '123456';


mysql> grant select,insert on mydb.* to admin3@'%.benet.com' identified by 'pw456';


●查看权限


SHOW GRANTS FOR 用户名@域名或IP


mysql> show grants for root@'localhost';


●撤销权限


REVOKE 权限列表 on 数据库名.表名 from 用户名@域名或者IP


revoke all on mydb.* from admin3@'%.benet.com';


=======================


重置MySQL的root用户密码


●已经知道mysql数据库的root密码


# 方法一:在shell环境中,使用mysqladmin命令设置(需要知道原密码)


[root@CentOS ~]# mysqladmin -u root -p password "123456"


# 方法二:在“mysql>”环境中,使用update命令,直接更新mysql库user表的数据


[root@CentOS ~]# mysql -u root -p


mysql> update mysql.user set password=password('123456') where user='root';


mysql> flush privileges;


# 方法三:在“mysql>”环境中,使用grant命令,修改root用户的授权权限。


mysql>GRANT ALL ON *.* TO root@'localhost' IDENTIFIED BY '123456';


●忘记mysql数据库的root用户的密码


# 关闭mysql服务


service mysqld stop


# 或者


killall mysqld


# 使用myslq_safe脚本以安全模式(不加载授权表)启动mysqld服务(数据库位非默认值需要用--datadir指定)


/usr/local/mysql/bin/mysqld_safe --skip-grant-table --datadir=/var/mysql/data &


# 使用空密码的root用户登录数据库,重新设置root的密码


[root@CentOS ~]# mysql -u root


mysql> update mysql.user set password=password('123456') where user='root';


mysql> flush privileges;


首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇SQLite3中存储类型和数据类型结合.. 下一篇REGEXP_SUBSTR函数的整理

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: