[Linux]Ubantu20.04下使用apt方式安装MySql8.0.21过程中不提示设置密码的解决方法

ubuntu19.+升级到 ubuntu20.04 过程中出错,直接重装系统后配置环境

终端apt下载mysql过程中无弹窗提示设置账户密码

找了很多方法可能是版本的原因都不好使

兜兜转转最后解决了记录一下留给有缘人

 

NOTE:  

  如果你是卸载MySql重装的话,MySql没卸载干净也不会提示设置密码,需要将MySql彻底卸载干净再重装

 

下载sql:

1 sudo apt-get update
2 sudo apt-get install -y mysql-server mysql-client

 

查阅系统分配的初始账号和密码:

1 sudo gedit /etc/mysql/debian.cnf 

 

显示:

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

 

用这个账户登录MySql

user: debian-sys-maint

password: aewAdwuHBQVe4IjO

1 mysql -u debian-sys-maint -p
2 Enter password: 输入密码 

如果登录失败在登录语句前加 sudo

 

登录成功会显示:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.21-0ubuntu0.20.04.4 (Ubuntu)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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> 

登录成功后修改root密码:

1 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码';

最后退出:

exit;

现在用root账户登录就行了。

 

如果登录出现下面报错:

ERROR 1698 (28000): Access denied for user 'mrcangye'@'localhost'

那么在登录时,语句前面加sudo就可以登录了

 

解决加sudo便能正常登录:

进入mysql:

sudo -udebian-sys-maint -paewAdwuHBQVe4IjO

登录成功后输入以下以下语句:

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '你的密码';

 

最后exit:

exit;
posted @ 2020-08-09 12:23  Minos_t  阅读(747)  评论(0编辑  收藏  举报