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:~$ 
  • 相关阅读:
    关于echarts图表在tab页中width:100%失效的问题
    easyui
    小程序中点击事件传参
    微信小程序实现滚动分页加载更多
    使用jquery如何获取现在时间、并且格式化
    只需两步获取任何微信小程序源码
    怎样修改已经审核通过发布成功的微信小程序
    小程序开发swiper如何实现点击图片自定义跳转
    微信小程序如何提交审核并发布?发布问题:小程序只支持https访问
    小程序填坑之路—读取用户信息、缓存其数据、读取其数据
  • 原文地址:https://www.cnblogs.com/herd/p/12939555.html
Copyright © 2011-2022 走看看