1698无法登录mysql服务器,MySQL“错误1698(28000):对用户'root'@'localhost'的访问被拒绝”...

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

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)

Similarly, as a root user,

kurt@kurt-ThinkPad:~$ mysql -u root

ERROR 1698 (28000): Access denied for user 'root'@'localhost'

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

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

Any ideas on how to get MySQL to work?

解决方案

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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值