ssssubuntu 20.04 默认源安装 mysql版本为 8.0 版本
与以往的版本不同,安装过程自动初始化数据文件,自行开启服务
安装期间并无输入root密码选项
检查安装过程提示,也未发现系统随机密码提示
查阅资料发现直接利用 mysql 账户登录命令行修改 root 密码最为便捷
1. 安装mysql8.0
royakon@hwsrv-832112:~$ sudo apt-get update
royakon@hwsrv-832112:~$ sudo apt-get upgrade
royakon@hwsrv-832112:~$ sudo apt-get install mysql-server
2. mysql 账户登录并更新 root 密码
royakon@hwsrv-832112:~$ mysql
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5650
Server version: 8.0.25-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>use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>alter user 'root'@'localhost' identified with mysql_native_password by '123456';
mysql>exit
3. 重新用刚刚设置的 root 账号密码进行登录测试
royakon@hwsrv-832112:mysql -u root -p