ubuntu mysql8.0.19忘记root密码

和普通的修改密码不太一样

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(‘123456‘) where user=‘root‘ and Host=‘localhost‘‘ at line 1

 

(base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf(base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ sudo service mysql restart(base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 7Server version: 8.0.19 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> mysql> mysql> mysql> mysql> mysql> select mysql.user Host,User,plugin,authentication_string;ERROR 1109 (42S02): Unknown table ‘mysql‘ in field listmysql> mysql> mysql> mysql> select Host,User,plugin,authentication_string from mysql.user;+-----------+------------------+-----------------------+------------------------------------------------------------------------+| Host | User | plugin | authentication_string |+-----------+------------------+-----------------------+------------------------------------------------------------------------+| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED || localhost | mysql.session | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED || localhost | mysql.sys | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED || localhost | root | caching_sha2_password | e10adc3949ba59abbe56e057f20f883e |+-----------+------------------+-----------------------+------------------------------------------------------------------------+4 rows in set (0.01 sec)mysql> mysql> mysql> mysql> mysql> mysql> update mysql.user Set authentication_string=caching_sha2_password(‘123456‘) where user = ‘root‘;ERROR 1046 (3D000): No database selectedmysql> mysql> mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> mysql> mysql> update user Set authentication_string=caching_sha2_password(‘123456‘) where user = ‘root‘;ERROR 1305 (42000): FUNCTION mysql.caching_sha2_password does not existmysql> mysql> mysql> mysql> update user Set authentication_string=‘‘ where user = ‘root‘;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘‘ where user = ‘root‘‘ at line 1mysql> mysql> mysql> update user Set authentication_string=‘‘ where user = ‘root‘;Query OK, 1 row affected (0.09 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> mysql> mysql> mysql> mysql> mysql> mysql> quit;Bye(base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License, version 2.0,# as published by the Free Software Foundation.## This program is also distributed with certain software (including# but not limited to OpenSSL) that is licensed under separate terms,# as designated in a particular file or component or in included license# documentation. The authors of MySQL hereby grant you an additional# permission to link the program and your derivative works with the# separately licensed software that they have included with MySQL.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License, version 2.0, for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA## The MySQL Server configuration file.## For explanations see# http://dev.mysql.com/doc/mysql/en/server-system-variables.html[mysqld]pid-file = /var/run/mysqld/mysqld.pidsocket = /var/run/mysqld/mysqld.sockdatadir = /var/lib/mysqllog-error = /var/log/mysql/error.logskip-grant-tables(base) gbt@gbt-Precision-7720:~$(base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ sudo service mysql restart(base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.0.19 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> mysql> mysql> mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> mysql> mysql> mysql> mysql> mysql> ALTER user ‘root‘@‘localhost‘ identified with caching_sha2_password by ‘123456‘;Query OK, 0 rows affected (0.08 sec)mysql> mysql> mysql> mysql> mysql> flush privileges;Query OK, 0 rows affected (0.04 sec)mysql> mysql> mysql> mysql> exit;Bye(base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ sudo service mysql restart(base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.0.19 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> mysql> mysql> mysql> exit;Bye(base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ (base) gbt@gbt-Precision-7720:~$ 

 

相关文章