• mysql8 安装后无法登录的问题


    使用 apt 安装mysql 先search一下

    sudo apt search mysql

    得到结果

    找到了这个 发现是8 那就装吧

    sudo apt-get install mysql-server

    安装后发现无法登录

    $ mysql -uroot -p
    Enter password: 
    ERROR 1698 (28000): Access denied for user 'root'@'localhost'

    此时可以查看 文件

    $ sudo cat /etc/mysql/debian.cnf 
    # Automatically generated for Debian scripts. DO NOT TOUCH!
    [client]
    host     = localhost
    user     = debian-sys-maint
    password = koJJxVpPDRINkIE6
    socket   = /var/run/mysqld/mysqld.sock
    [mysql_upgrade]
    host     = localhost
    user     = debian-sys-maint
    password = koJJxVpPDRINkIE6
    socket   = /var/run/mysqld/mysqld.sock

    然后使用这个用户密码登录

    mysql -u debian-sys-maint -pkoJJxVpPDRINkIE6

    发现可以登录进来  然后选择 mysql 数据库

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.08 sec)
    
    mysql> use mysql;

    改密码 刷新权限

    mysql> alter user 'root'@'localhost' identified with mysql_native_password by '新密码';
    Query OK, 0 rows affected (0.10 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.01 sec)

    然后退出使用新密码重新登录看到可以登录了

    $ mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 15
    Server version: 8.0.23-0ubuntu0.20.04.1 (Ubuntu)
    
    Copyright (c) 2000, 2021, Oracle and/or its affiliates.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.00 sec)
    
    mysql> exit
    Bye
  • 相关阅读:
    golang 常见疑惑总结
    golang 详解defer
    golang调试工具Delve
    ACE的源码划分
    通过#define连接字符串的特殊方法[转]
    转:extern "C"的用法解析
    转:3d max 2013 安装教程,凭着一种互联网精神提供给广大朋友
    转:Bullet物理引擎不完全指南(Bullet Physics Engine not complete Guide)
    转:折腾一晚上Bullet及Ogre相关工具的成果 -- 3Ds Max,Maya, blender, GameKit
    转:CMake快速入门教程-实战
  • 原文地址:https://www.cnblogs.com/lizhaoyao/p/14662968.html
Copyright © 2020-2023  润新知