首页 🧐痛みの开端

大佬绕道申明

错误描述:

root@localhost: pqhVj_eJL3>u




mysqld --initialize --user=root --console初始化生成的密码怎么填都不对,没搞明白是为什么。难道是我mysql版本太高了?

这里还得感谢Mars-xq大佬的文章,鄙人借鉴一二

无密码启动MySQL服务

C:\WINDOWS\system32>mysqld --console --skip-grant-tables --shared-memory
...
Plugin mysqlx reported: 'All I/O interfaces are disabled, X Protocol won't be accessible'

再打开一个cmd窗口

注意上一个窗口不要关掉!!!

//无密码【登陆】(密码处直接enter)
C:\WINDOWS\system32>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.16 MySQL Community Server - GPL

设置【空密码】

//无密码【登陆】(密码处直接enter)
C:\WINDOWS\system32>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.16 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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> UPDATE mysql.user SET authentication_string='' WHERE user='root' and host='localhost';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

//刷新
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

//查询
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 |                                                                        |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)

//修改密码
mysql> alter user user() identified by "123456";
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'skip-grants host'
mysql> ALTER user 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'admin';
Query OK, 0 rows affected (0.01 sec)

//刷新
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

//查询
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 | $A$005$?7w"6WrD"DD1&>Hv     0pjBL.Pm2vz22d48dZyXFltpkom2giwuyY5Aq836U.5 |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)

腊鸡

C:WINDOWSsystem32>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 12
Server version: 8.0.16 MySQL Community Server - GPL

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

Oracle is a registered trademark of Oracle Corporation and/or its

  1. Other names may be trademarks of their respective
    owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> show databases;
Database
information_schema
mysql
performance_schema
sys

4 rows in set (0.00 sec)

mysql> use mysql;
Database changed

mysql> show tables;
Tables_in_mysql
columns_priv
component
db
default_roles
engine_cost
func
general_log
global_grants
gtid_executed
help_category
help_keyword
help_relation
help_topic
innodb_index_stats
innodb_table_stats
password_history
plugin
procs_priv
proxies_priv
role_edges
server_cost
servers
slave_master_info
slave_relay_log_info
slave_worker_info
slow_log
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user

33 rows in set (0.00 sec)
mysql> select * from userG
...
...
...
4 rows in set (0.00 sec)
mysql> quit
Bye




扫描二维码,在手机阅读!
文章评论

目录