• 104505

    文章

  • 803

    评论

  • 12

    友链

  • 最近新加了换肤功能,大家多来逛逛吧~~~~
  • 喜欢这个网站的朋友可以加一下QQ群,我们一起交流技术。

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:~$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.19 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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 list
mysql> 
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 selected
mysql> 
mysql> 
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> 
mysql> 
mysql> update user Set authentication_string=caching_sha2_password('123456') where user = 'root';
ERROR 1305 (42000): FUNCTION mysql.caching_sha2_password does not exist
mysql> 
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 1
mysql> 
mysql> 
mysql> update user Set authentication_string='' where user = 'root';
Query OK, 1 row affected (0.09 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> 
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.pid
socket        = /var/run/mysqld/mysqld.sock
datadir        = /var/lib/mysql
log-error    = /var/log/mysql/error.log

skip-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 -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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 names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> 
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 -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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:~$

 


695856371Web网页设计师②群 | 喜欢本站的朋友可以收藏本站,或者加入我们大家一起来交流技术!

0条评论

Loading...


自定义皮肤 主体内容背景
打开支付宝扫码付款购买视频教程
遇到问题联系客服QQ:419400980
注册梁钟霖个人博客