zoukankan      html  css  js  c++  java
  • 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:~$ 
  • 相关阅读:
    springboot整合mybatis实现增删改查小案例
    浅谈Nginx负载均衡原理与实现
    使用Cordova框架把Webapp封装成Hybrid App实践——Android篇
    ActiveMQ结合WebScoket应用例子以及介绍
    个人简介
    C#中的属性,字段,变量
    Aspose.Words 直接写response导出docx文档显示文件已损坏需要修复的解决办法
    System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(string, string)已过时的解决办法
    Aspose.Words:如何添加另一个WORD文档中的Node对象
    基于CPS变换的尾递归转换算法
  • 原文地址:https://www.cnblogs.com/herd/p/12939555.html
Copyright © 2011-2022 走看看