gpt4 book ai didi

MySQL "ERROR 1698 (28000): Access denied for user ' 根'@'localhost'“

转载 作者:行者123 更新时间:2023-11-29 01:20:17 25 4
gpt4 key购买 nike

我已经安装了以下版本的 MySQL:

kurt@kurt-ThinkPad:~$ mysql -V
mysql Ver 14.14 Distrib 5.7.15, for Linux (x86_64) using EditLine wrapper

我记得我在安装过程中没有为 root 用户设置密码。但是,如果我尝试使用 mysql 命令简单地启动它,我会收到以下错误:

kurt@kurt-ThinkPad:~$ mysql
ERROR 1045 (28000): Access denied for user 'kurt'@'localhost' (using password: NO)

同样,作为root用户,

kurt@kurt-ThinkPad:~$ mysql -u root
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

我尝试按照 Resetting the Root Password: Unix and Unix-Like Systems 上的说明进行操作;我在我的主目录中创建了文本文件,并从那里尝试使用 --init-file 选项启动 MySQL 服务器。但是,我再次遇到权限错误:

kurt@kurt-ThinkPad:~$ mysqld_safe --init-file=mysql-init &
[1] 18340
kurt@kurt-ThinkPad:~$ /usr/bin/mysqld_safe: 548: /usr/bin/mysqld_safe: cannot create /var/lib/mysql/mysqld_safe.pid: Permission denied
2016-09-20T14:57:04.753720Z mysqld_safe Logging to '/var/log/mysql/error.log'.
cat: /var/run/mysqld/mysqld.pid: Permission denied
rm: cannot remove '/var/run/mysqld/mysqld.pid': Permission denied
2016-09-20T14:57:04.780206Z mysqld_safe Fatal error: Can't remove the pid file:
/var/run/mysqld/mysqld.pid
Please remove it manually and start /usr/bin/mysqld_safe again;
mysqld daemon not started
/usr/bin/mysqld_safe: 135: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
rm: cannot remove '/var/lib/mysql/mysqld_safe.pid': Permission denied

我在 Cant connect to Mysql server ; Can't create/write the pid file 中读到了类似的错误,其中建议的解决方案是将 MySQL 用户分配到 /var/run/mysqld 目录。但是,如果我尝试这样做,我会得到“不允许操作”:

kurt@kurt-ThinkPad:~$ chown mysql:mysql /var/run/mysqld
chown: changing ownership of '/var/run/mysqld': Operation not permitted

关于如何让 MySQL 工作的任何想法?

最佳答案

我注意到一种解决方案是使用 sudo 运行 mysql:

kurt@kurt-ThinkPad:~$ sudo mysql
sudo: unable to resolve host kurt-ThinkPad
[sudo] password for kurt:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.7.15 MySQL Community Server (GPL)

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

(我从 https://bbs.archlinux.org/viewtopic.php?id=154010 得到这个建议)。

关于MySQL "ERROR 1698 (28000): Access denied for user ' 根'@'localhost'“,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39597682/

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