zoukankan      html  css  js  c++  java
  • MySQL:用户,权限,配置文件,忘记root密码

    mysql中的用户是使用 用户名@ip 来标识的

    增删改查:

    mysql> create user yang@'10.0.0.1' identified by '123';
    mysql> create user yang@"%" identified by '123';
    mysql> drop user yang@'10.0.0.1';
    mysql> alter user root@'%' identified by '123456';
    mysql> select User,Host,authentication_string from mysql.user;

    权限管理 

    grant 权限  on 范围  to  用户  identified by 密码;
    
    权限:
        ALL : SELECT,INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, 
        REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES,
        EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, 
        SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE
        with grant option
    范围:
    *.*       chmod xxx -R /
    库.*      chmod xxx -R /oldguo
    库.表     chmod xxx -R /oldguo/a.txt 
    
    mysql> grant all on *.* to oldguo@'10.0.0.%' identified by '123';
    mysql> grant SELECT,INSERT, UPDATE, DELETE on *.* to oldboy@'10.0.0.%' identified by '123';
    
    revoke
    mysql> show grants for oldboy@'10.0.0.%';
    mysql> revoke delete on *.* from oldboy@'10.0.0.%';
    mysql> show grants for oldboy@'10.0.0.%';

    配置文件

    (1) 默认读取顺序
    [root@db01 ~]# mysqld --help --verbose |grep my.cnf
    /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

    忘记root密码

    (1) 关闭数据库,并启动到安全模式
    [root@db01 ~]# systemctl stop mysqld
    [root@db01 ~]# mysqld_safe --skip-grant-tables --skip-networking &
    (2) 登录数据库修改密码
    mysql> flush privileges;
    mysql> alter user root@'localhost' identified by '1';
    
    (3) kill掉mysqld_safe进程
    [root@db01 ~]# ps aux | grep mysql
    [root@db01 ~]# kill -9 xxx
    
    (3) 正常重启数据库
    [root@db01 ~]# systemctl start mysqld
  • 相关阅读:
    一些網址
    mousedown、mouseup、click事件之间的关系及执行顺序
    快速的画一个三角形
    在较小的屏幕下展示一个超宽的图片,如何让图片居中显示?
    Python 模块安装的一些问题
    Python Django 的使用
    Python WEB框架的介绍
    Python 几个前端插件的简单使用
    Python JQuery 正则表达式mini版
    HC蓝牙模块
  • 原文地址:https://www.cnblogs.com/jec1999/p/11678572.html
Copyright © 2011-2022 走看看