ubuntu change mysql root password

When using streamset require users to link mysql there is a root user privileges
but mysql initial root user without a password, there may be I forgot my password

$ mysql -u root

This can not access
it

$ sudo mysql -u root

You can visit
us first think of a way to go:

$ sudo /etc/init.d/mysql stop
$ sudo /usr/bin/mysql_safe --skip-grant-tables --skip-networking &

If errors are reported on the new directory

$ sudo mkdir -p /var/run/mysqld
$ sudo chown mysql:mysql /var/run/mysqld #不要修改用户名

Restart mysql

$ sudo /usr/bin/mysql_safe --skip-grant-tables --skip-networking &

Now enter:

$ mysql -u root

You should be able to go in the
input go after:

mysql> use mysql;
mysql> update user set authentication_string=PASSWORD('!QAZ2wsx') where user='root'; #密码有强度要求

mysql> update user set plugin='mysql_native_password";

mysql> flush privileges;
mysql> quit; 

At this point again

$ mysql -u root -p
password:

Enter the password should be on it.

Published 73 original articles · won praise 7 · views 10000 +

Guess you like

Origin blog.csdn.net/yao09605/article/details/104101433