本文介绍了Ubuntu 18.04在没有root特权的情况下启动mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了ubuntu 18.04并在其上安装了LAMP,但是在没有root特权的情况下使用mysql遇到了麻烦.当我写的时候:

I just installed ubuntu 18.04 and installed LAMP on it, however I had trouble using mysql without the root privilege. when I write:

并输入我配置的密码,它将导致访问被拒绝.除非我写

and enter the password I configured it throws access denied. unless if I write

,然后输入我可以连接的密码.但是我不想要sudo原因,因为它会阻止工作台连接到mysql,同样适用于phpmyadmin.关于如何解决该问题的任何提示?

and enter the password that I'm able to connect. But I don't want the sudo cause it prevents having workbench to connect to mysql, same applies to phpmyadmin too. Any hints on how to fix that?

推荐答案

它只能是需要sudo的"-u root"用户.最好不要使用root来进行大多数访问,因此只需使用sudo作为root登录并创建一个新用户即可:

It should only be the "-u root" user that requires sudo. It's good practice to not use root for most access anyways, so just login as root using sudo and create a newuser:

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON database_name.* TO 'newuser'@'localhost';

然后,您应该能够在没有sudo的情况下访问"mysql -u newuser".

Then you should be able to access "mysql -u newuser" without sudo.

这篇关于Ubuntu 18.04在没有root特权的情况下启动mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 13:14