• mysql修改密码


    1.mysql5.7以后和8.0版本的修改方法

    摘要:经常会遇到mysql忘记密码,以及在公司中,交接没有完成导致无法进入数据库,下面提供了mysql的修改密码方法和使用图形化工具连接数据库的方法以及不需要密码直接进入数据库。

    启动mysqld进程时,为其使用如下选项:
    –skip-grant-tables
    –skip-networking

    [root@server ~]# vim /etc/my.cnf
    [mysqld]
    skip-grant-tables
    skip-networking    # MySQL8.0不需要
    [root@server ~]# systemctl restart mysqld
    #方法1
    mysql> update mysql.user set authentication_string='' where user='root' and host='localhost';
    #方法2
    mysql> flush privileges;
    # 再执行下面任意一个命令
    mysql> alter user root@'localhost' identified by '123456';
    mysql> set password for root@'localhost'='123456';
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    摘要:使用图形化连接工具连接mysql数据库,在8.0以后的版本时不能直接连接的
    在MySQL数据库中创建用户并授权后,可以使用相关图形化工具进行远程的管理

    2.使用root登录
    mysql -uroot -p
    
    • 1
    3.设置服务可被所有远程客户端访问
    select Host,User from mysql.user;        -- 查询到他的host为localhost
    update mysql.user set Host = '%' where user = 'root';  -- 将其修改为所有或者具体的ip地址
    flush privileges;
    
    • 1
    • 2
    • 3

    image.pngimage.png

    4.关闭防火墙
    systemctl disable firewalld   ---永久关闭防火墙
    systemctl stop firewalld      ---暂时关闭防火墙
    
    systemctl status firewalld  -- 查看防火墙状态
    systemctl restart firewalld.service  -- 重启防火墙
    
    • 1
    • 2
    • 3
    • 4
    • 5
    5.重启mysql服务
    systemctl restart mysqld     ---重启mysql服务
    
    • 1
    6.使用Navicat 连接

    使用虚拟机的ip地址作为主机,输入数据库的用户名和密码,进行测试连接
    image.png

  • 相关阅读:
    世界互联网大会领先科技奖发布 百度知识增强大语言模型关键技术获奖
    【蓝桥】健身
    OpenCV自学笔记十六:直方图处理
    Unix System V BSD POSIX 究竟是什么?
    C语言中的结构体和联合体有什么区别?
    3.6 样式绑定
    分库分表实战:竿头日上—千万级数据优化之读写分离
    Python基础语法
    Ioc容器加载过程-bean生命周期源码解析
    LiteOS-M内核
  • 原文地址:https://blog.csdn.net/m0_50816276/article/details/132793373