V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
zhangpanda
V2EX  ›  Ubuntu

Ubuntu 18.04 安装 mysql-server 5.7 时未提示输入密码的解决办法

  •  
  •   zhangpanda · Feb 26, 2019 · 2308 views
    This topic created in 2620 days ago, the information mentioned may be changed or developed.

    今天装 mysql-server 5.7 时发现一直没让输入密码,郁闷,找了下解决方法特此记录。

    打开系统配置文件

    sudo vim /etc/mysql/debian.cnf

    找到里面的 password 项

    password = ***********

    找到 password 后这段长密码,复制下来

    mysql -u debian-sys-maint -p

    粘贴密码登录

    在 mysql 里执行以下命令

    use mysql;

    update user set authentication_string=PASSWORD("自定义密码") where user='root';

    update user set plugin="mysql_native_password";

    flush privileges;

    quit;

    重启 mysql

    service mysql restart

    重新连接 mysql

    mysql -u root -p

    输入自定义密码

    OK 搞定了

    3 replies    2020-07-08 00:58:01 +08:00
    alvinbone88
        1
    alvinbone88  
       Feb 26, 2019
    mysql_secure_installation 了解一下
    zhangpanda
        2
    zhangpanda  
    OP
       Feb 26, 2019
    @alvinbone88 多谢多谢 本菜鸟受教了
    KalaSearch
        3
    KalaSearch  
       Jul 8, 2020
    是的,用 mysql_secure_installation 方便很多

    我尝试了下很有可能是当时你的 mysql service 没起来。参考: https://kalasearch.cn/community/tutorials/ubuntu-20-04-install-mysql/
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   981 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 23:02 · PVG 07:02 · LAX 16:02 · JFK 19:02
    ♥ Do have faith in what you're doing.