ubuntu no password or forgotten password Solution When first install mysql

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/LXJRQJ/article/details/96832836

This article is mounted directly solve the Ubuntu command line when installing MySQL, the root password is not initialized question
1. First, enter the following command

sudo cat /etc/mysql/debian.cnf

2. Enter the following commands

mysql -u debian-sys-maint -p

// Note! This instruction password is entered in the password information obtained in the first instruction = ZCt7QB7d8O3rFKQZ come
// please fill out according to their actual situation!

3. To change the password, the password to modify this article to root, user definable

1. use mysql; 
2.//下面这句命令有点长,务必注意 update mysql.user set
3.authentication_string=password('root') where user='root' and Host
4.='localhost'; update user set plugin="mysql_native_password";  flush privileges;

4. Restart mysql:

Service restart MySQL 1.sudo
2.mysql -u root -p
After starting the input 3.// have modified a good password: root

https://img-blog.csdnimg.cn/20181121171826980.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0FuZHJld19aaG91Qw==,size_15,color_FFFFFF,t_70

Guess you like

Origin blog.csdn.net/LXJRQJ/article/details/96832836