ubantu在线装 mysql 密码问题_Ubuntu新安装mysql root密码问题

使用 sudo apt install  mysql-server 安装的mysql root密码你不知道吧,看如下资料:

https://stackoverflow.com/questions/42421585/default-password-of-mysql-in-ubuntu-server-16-04/49778695

I had a fresh installation of mysql-server on Ubuntu 18.10 and couldn't login with default password. Then only I got to know that by default root user is authenticated using auth_socket. So as in the answer when the plugin changed to mysql_native_password, we can use mysql default password

$ sudo apt install mysql-server

$ sudo cat /etc/mysql/debian.cnf

You can find the following lines in there

user     = debian-sys-maint

password = password_for_the_user

Then:

$ mysql -u debian-sys-maint -p

Enter password:

type the password from debian.cnf

mysql> USE mysql

mysql> SELECT User, Host, plugin FROM mysql.user;

+------------------+-----------+-----------------------+

| User             | Host      | plugin                |

+------------------+-----------+-----------------------+

| root             | localhost | auth_socket           |

| mysql.session    | localhost | mysql_native_password |

| mysql.sys        | localhost | mysql_native_password |

| debian-sys-maint | localhost | mysql_native_password |

+------------------+-----------+-----------------------+

4 rows in set (0.00 sec)

mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';

mysql> COMMIT;

Either:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

Or:

// For MySQL 5.7+

mysql>UPDATE mysql.user SET authentication_string=PASSWORD('new_password') where user='root';

shareimprove this answer

edited Feb 14 at 10:17

answered Jan 13 at 2:26

Yasii

38938

You should add some details as to what OP was doing wrong, and why this solution works – schu34 Jan 13 at 2:34

You should add that context as an edit to your answer :) – schu34 Jan 13 at 14:30

I had to restart mysql server after do this solution. sudo service mysql restart – Tuxman May 11 at 20:05

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值