一 安装MySQL

sudo apt-get update

sudo apt-get install mysql-server

二 密码问题

1 安装时提示设置密码

这种情况没什么问题,通过已下命令登录MySQL

mysql -u root -p

2 安装时没有提示设置密码

这种情况可以尝试使用空密码进行登录

3 安装时没有提示设置密码且空密码无法登录

我在安装MySQL时遇到没有提示设置密码且空密码无效的情况,报错信息如下:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

三 解决方案(也可以用于忘记root密码)

Ubuntu在安装MySQL时会为用户创建一个debian-sys-maint用户我们可以通过这个用户来设置

1 查看debian-sys-maint密码

sudo cat /etc/mysql/debian.cnf

2 登录debian-sys-maint用户

mysql -u debian-sys-maint -p

注意:此时密码为刚刚查到的密码

现在我们已经登录到MySQL了

3 设置root密码

use mysql;

update mysql.user set authentication_string=password('你的密码') where user='root' and Host ='localhost';

update user set plugin="mysql_native_password";

flush privileges;

quit;

OK! 问题解决了

参考原贴

Ubuntu18.04安装MySQL(未设置密码或忘记密码)的更多相关文章

  1. ubuntu18.04 首次登录mysql未设置密码或忘记密码解决方法

    1.首先输入以下指令: sudo cat /etc/mysql/debian.cnf运行截图如下: 2. 再输入以下指令: mysql -u debian-sys-maint -p//注意! //这条 ...

  2. ubuntu18.04 安装mysql不出现设置 root 帐户的密码问题(装)

    ubuntu18.04 安装mysql不出现设置 root 帐户的密码问题      https://blog.csdn.net/NeptuneClouds/article/details/80995 ...

  3. Ubuntu18.04 安装MySQL(Linux)解决登陆权限问题及Navicat for mysql 中文乱码问题

    一.MySQL(Linux)解决登陆权限问题 Ubuntu18.04 安装mysql或者mariadb之后,发现普通用户和远程都没有权限连接. ERROR 1045: Access denied fo ...

  4. ubuntu18.04安装mysql以及重置密码创建新用户

    1.安装mysqlsudo apt-get install mysql-serversudo apt-get install mysql-clientsudo apt-get install libm ...

  5. ubuntu18.04安装mysql

    ubuntu18.04中,默认情况下mysql默认包含在apt软件存储库中,要安装它只需要更新服务器上的包索引并安装默认包apt-get. 1.安装mysql sudo apt-get update ...

  6. Ubuntu18.04安装MySQL教程

    Ubuntu18.04下安装MySQL 提示:以下操作均在root权限下进行. # 查看有没有安装MySQL: dpkg -l | grep mysql # 安装MySQL: apt install ...

  7. ubuntu18.04 安装mysql server

    mysql 5.7支持的最高版本是Ubuntu17 ,即使安装成功后,也会出现各种妖蛾子,本人就被这种问题困扰了好一会.在Ubuntu 18.04下安装mysql,建议安装8.0以上版本! 1. 配置 ...

  8. Ubuntu18.04安装mysql(AWS云)

    1.执行如下三条命令 sudo apt-get install mysql-server sudo apt install mysql-client sudo apt install libmysql ...

  9. [linux] Ubuntu18.04 安装mysql密码不对

    安装 安装过程可以说是非常简单了 sudo apt-get install mysql-server 然后看看有没有启动成功 systemctl status mysql 看到状态是 running就 ...

随机推荐

  1. console.clear

    console.clear Chrome console.clear && console.clear() refs xgqfrms 2012-2020 www.cnblogs.com ...

  2. prefetch & preload & prerender & dns-prefetch & preconnect

    prefetch & preload & prerender & dns-prefetch & preconnect performance optimization ...

  3. prototype chain & prototype & __proto__

    prototype chain & prototype & proto prototype chain MDN https://developer.mozilla.org/en-US/ ...

  4. UTM & User Tracking Message

    UTM & User Tracking Message utm_source https://marketingplatform.google.com/about/resources/link ...

  5. 视屏剪辑软件 & free video editor

    视屏剪辑软件 & free video editor purpose add animation keyframe to tutorials video vlog demos tutorial ...

  6. WiFi & QR Code

    WiFi & QR Code https://github.com/bndw/wifi-card https://wifi.dev.bdw.to/ 扫码登录 WIFI:T:WPA;S:free ...

  7. Ethical Hacking Tutorials

    Ethical Hacking Tutorials Free Ethical Hacking Tutorials https://www.guru99.com/ethical-hacking-tuto ...

  8. js in depth: event loop & micro-task, macro-task & stack, queue, heap & thread, process

    js in depth: event loop & micro-task, macro-task & stack, queue, heap & thread, process ...

  9. PM2 in depth

    PM2 in depth ecosystem.config.js module.exports = { apps : [{ name: "app", script: ". ...

  10. ============================================ 微信小程序开发学习

    开发文档: https://developers.weixin.qq.com/miniprogram/dev/framework/