美文网首页
mysql的zip安装和重置密码

mysql的zip安装和重置密码

作者: 宋song一 | 来源:发表于2020-02-26 00:54 被阅读0次

    一、 windows10+mysql8.0.zip安装

    需要安装:微软常用软件运行库vc2015.32位版本.msi安装也需要

    64位 windows10,MYSQL8.0.13重置密码(忘记密码或者无法登录)

    1.打开命令窗口cmd,输入命令:net stop mysql,停止MySQL服务,
    任务管理器相关进程也需要关闭
    2.开启跳过密码验证登录的MySQL服务

        输入命令  
    
        mysqld --console --skip-grant-tables --shared-memory 
    

    成功信息

    2020-05-15T03:22:46.650979Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
    2020-05-15T03:22:46.651076Z 0 [System] [MY-010116] [Server] D:\mysql-8.0.19-winx64\bin\mysqld.exe (mysqld 8.0.19) starting as process 17860
    2020-05-15T03:22:47.521109Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
    2020-05-15T03:22:47.533022Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
    mysqld: File '.\binlog.000056' not found (OS errno 2 - No such file or directory)
    2020-05-15T03:22:47.564302Z 0 [ERROR] [MY-010958] [Server] Could not open log file.
    mysqld: File '.\binlog.000057' not found (OS errno 2 - No such file or directory)
    2020-05-15T03:22:47.567636Z 0 [ERROR] [MY-010958] [Server] Could not open log file.
    2020-05-15T03:22:47.573260Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
    2020-05-15T03:22:47.651243Z 0 [System] [MY-010931] [Server] D:\mysql-8.0.19-winx64\bin\mysqld.exe: ready for connections. Version: '8.0.19'  socket: ''  port: 0  MySQL Community Server - GPL.
    2020-05-15T03:22:47.669455Z 0 [Warning] [MY-011311] [Server] Plugin mysqlx reported: 'All I/O interfaces are disabled, X Protocol won't be accessible'
    

    3.再打开一个新的cmd,无密码登录MySQL,输入登录命令:mysql -u root -p

    4. 密码置为空,命令如下:

    use mysql
    
    update user set authentication_string='' where user='root';
    
    image

    5.退出mysql,执行命令: quit

    1. 关闭以-console --skip-grant-tables --shared-memory 启动的MySQL服务,

    2. 另开命令框,输入:net start mysql 启动MySQL服务。

    8.步骤4密码已经置空,所以无密码状态登录MySQL,输入登录命令:mysql -u root -p

    9.利用上一篇博客中更改密码的命令,成功修改密码,如下图:

    ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码'

    image.png

    10.验证更改后密码正确登录

    输入quit,退出当前登录,输入登录命令:mysql -u root -p

    输入密码,成功登录,到此,重置密码结束。

    image

    二、Ubuntu 安装

    rpm -qa | grep -i mysql 查找已安装MySQL版本
    rpm -e XXX(查找到的版本号) --nodeps 卸载mysql

    apt-cache search mysql-server 搜索
    sudo apt-get install mysql-server 安装(mysql-core可能不用安装)
    sudo vim /etc/mysql/debian.cnf 查看mysql用户名和密码(只安装mysql-core时,没有这个文件)
    修改用户名和密码:

    use mysql;
    //刷新权限
    flush privileges; 
    //修改用户名为root,密码为123456
    alter user 'root'@'localhost' identified by '123456'; 
    flush privileges;
    quit;
    

    service mysql restart; 重启服务并使用新的用户名和密码登录
    检查MySQL是否运行:
    sudo netstat -tap | grep mysql (需要安装netstat)

    此时数据库安装成功,但是只能本地访问,不能远程访问数据库,如果要远程访问则必须进行设置。首先修改mysql的配置文件
    在 /etc/mysql/mysql.conf.d 里,vim mysqld.cnf
    注释掉
    bind-address = 127.0.0.1
    保存退出

    授权
    GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;
    //刷新权限
    flush privileges;

    service iptabls status;查看防火墙状态
    service iptabls stop;关闭防火墙

    相关文章

      网友评论

          本文标题:mysql的zip安装和重置密码

          本文链接:https://www.haomeiwen.com/subject/wludchtx.html