gpt4 book ai didi

mysql - 我无法再以 root 身份访问 mysql

转载 作者:太空宇宙 更新时间:2023-11-04 04:55:20 24 4
gpt4 key购买 nike

我运行 Ubuntu 16.04 和 MYSQL 5.7。

更改localhost中root用户的访问权限后,我无法再进入MySQL,在互联网上搜索但没有找到解决方案。

我没有选择,有人有想法吗?当我看到服务器正在运行时,完全删除 MySQL 并重新安装似乎很奇怪。

我做了什么

mysqld stopped with
sudo /etc/init.d/mysql stop

startet with
sudo mysqld_safe --skip-grant-tables

jan@Linux01:~$ sudo mysql -uroot
[sudo] Passwort für jan:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
jan@Linux01:~$ service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Don 2018-01-04 22:24:15 CET; 5min ago
Process: 9021 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 9010 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 9020 (mysqld)
CGroup: /system.slice/mysql.service
└─9020 /usr/sbin/mysqld

Jän 04 22:24:14 Linux01 mysqld[9020]: 2018-01-04T21:24:14.847017Z 0 [Note] Event Scheduler: Loaded 0 events
Jän 04 22:24:14 Linux01 mysqld[9020]: 2018-01-04T21:24:14.847351Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Jän 04 22:24:14 Linux01 mysqld[9020]: Version: '5.7.20-0ubuntu0.16.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)
Jän 04 22:24:14 Linux01 mysqld[9020]: 2018-01-04T21:24:14.847384Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '-
Jän 04 22:24:14 Linux01 mysqld[9020]: 2018-01-04T21:24:14.847388Z 0 [Note] Beginning of list of non-natively partitioned tables
Jän 04 22:24:14 Linux01 mysqld[9020]: 2018-01-04T21:24:14.904105Z 0 [Note] End of list of non-natively partitioned tables
Jän 04 22:24:15 Linux01 mysqld[9020]: 2018-01-04T21:24:15.429487Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)
Jän 04 22:24:15 Linux01 systemd[1]: Started MySQL Community Server.

最佳答案

我不认为以这种方式停止 mysql 是真正的问题,但是输入 mysql 时有一个拼写错误 mysql -uroot 是完全,什么时候是 mysql -u root -p 加上你的密码。

正如你所见,我也是 Ubuntu 16.04 和 mysql 5.7:

mysql -u root -p

返回这个

mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, 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 -uroot

是的,您收到错误 1045(28000):访问被拒绝...

关于mysql - 我无法再以 root 身份访问 mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48104410/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com