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
  • 相关阅读:
    染色体共线性可视化
    Hi-C互作热图作图神器-HiCPlotter
    利用ONT测序检测真核生物全基因组甲基化状态
    scRNAseq benchmark 学习笔记
    友情链接
    关于
    TF目标检测API-Error: Argument must be a dense tensor: range(0, 3)
    python字符串使用
    Ubuntu下几个命令
    转::linux应用之gcc环境的安装
  • 原文地址:https://www.cnblogs.com/jec1999/p/11678572.html
Copyright © 2011-2022 走看看