MySQL“错误1698(28000):对用户'root'@'localhost'的访问被拒绝" [英] MySQL "ERROR 1698 (28000): Access denied for user 'root'@'localhost'"
问题描述
我已经安装了以下版本的MySQL:
I've installed MySQL with the following version:
kurt@kurt-ThinkPad:~$ mysql -V
mysql Ver 14.14 Distrib 5.7.15, for Linux (x86_64) using EditLine wrapper
我记得我在设置过程中没有为root用户设置密码.但是,如果尝试使用mysql
命令简单地启动它,则会出现以下错误:
I recall I did not set a password for the root user during setup. However, if I try to simply start it using the mysql
command, I get the following error:
kurt@kurt-ThinkPad:~$ mysql
ERROR 1045 (28000): Access denied for user 'kurt'@'localhost' (using password: NO)
类似地,作为root用户,
Similarly, as a root user,
kurt@kurt-ThinkPad:~$ mysql -u root
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
我尝试按照重置根密码:Unix上的说明进行操作和类似Unix的系统;我在主目录中创建了文本文件,然后尝试使用--init-file
选项启动MySQL服务器.但是,我再次收到权限错误:
I tried following the instructions on Resetting the Root Password: Unix and Unix-Like Systems; I made the text file in my home directory, and from there tried to start the MySQL server with the --init-file
option. However, I again get a permissions error:
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
我在无法连接到Mysql服务器;无法创建/写入pid文件,其中建议的解决方案是将MySQL用户分配到/var/run/mysqld
目录.但是,如果尝试此操作,则会显示不允许操作":
I have read about a similar error in Cant connect to Mysql server ; Can't create/write the pid file, where the proposed solution is to assign the MySQL user to the /var/run/mysqld
directory. However, if I try this I get "Operation not permitted":
kurt@kurt-ThinkPad:~$ chown mysql:mysql /var/run/mysqld
chown: changing ownership of '/var/run/mysqld': Operation not permitted
关于如何使MySQL工作的任何想法吗?
Any ideas on how to get MySQL to work?
推荐答案
我注意到一种解决方案是使用sudo
运行mysql
:
I've noticed that one solution is to run mysql
with sudo
:
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“错误1698(28000):对用户'root'@'localhost'的访问被拒绝"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!