步骤如下:

1.获取mysql-apt-config 工具

wget https://dev.mysql.com/get/mysql-apt-config_0.8.11-1_all.deb

2.安装config 工具 第一项点进去选择5.7(默认是8.0)

dpkg -i mysql-apt-config_0.8.11-1_all.deb

3.更新源
sudo apt-get update

4.安装mysqk
sudo apt-get install mysql-server

5.理论上讲,上一步过程中可能会出现输入密码,但是这里说下没有出现密码的选项的解决方案【没有产生初始化密码 /vsr/log/mysqld.log】

终端输入: sudo cat /etc/mysql/debian.cnf

显示内容:

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = PGBiNPneSGXRlayQ
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = PGBiNPneSGXRlayQ
socket   = /var/run/mysqld/mysqld.sock

其中有user和password可以用来登录,登录后再修改密码;

终端输入:mysql -u debian-sys-maint -p ,再输入密码后,进入mysql中

elcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.24-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2018, 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>

在mysql客户端中输入依次输入以下内容:

mysql> show databases;
mysql> use mysql;
mysql> update user set authentication_string=PASSWORD("root") where user="root";

mysql> update user set plugin="mysql_native_password";
mysql> flush privileges;
mysql> quit;

其中PASSWORD后面的root可以为其他自定义的密码,

在终端中输入 sudo /etc/init.d/mysql restart; 命令,重启mysql服务

使用新密码登录mysql:mysql -u root -p

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: mysqlUbuntu