用于/var/lib/mysql的chown从根目录更改所有者,现在在mysql中出现错误1049(42000) [英] Used chown for /var/lib/mysql to change owner from root, now getting Error 1049 (42000) in mysql

查看:727
本文介绍了用于/var/lib/mysql的chown从根目录更改所有者,现在在mysql中出现错误1049(42000)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Ubuntu上,我以前在终端中使用以下代码创建了一个mysql数据库:

With Ubuntu, I previously created a mysql database using the following code in the terminal:

$ my sql -u root -p

然后在mysql中:

CREATE DATABASE securities_master;

我试图使用文件浏览器查看与此数据库有关的内容.但是因为我没有打开/var/lib/mysql文件夹的权限,所以我想更改此文件夹的权限.我在stackoverflow上进行了一些搜索,但是在没有完全了解我在做什么的情况下,我使用了以下内容(我的用户名是wei):

I was trying to use file explorer to view the contents related to this database. But because I did not have permissions to open the folder /var/lib/mysql I wanted to change the permissions on this folder. I did some searching on stackoverflow, and without fully understanding what I was doing, I used something like the following (my username being wei):

sudo chown -R root:wei /var/lib/mysql

或(不幸的是,我已经关闭了终端窗口,所以不确定确切输入的内容)

OR (unfortunately I had since closed terminal window so not sure exactly what I typed)

sudo chown -R wei:wei /var/lib/mysql

OR

sudo chown -R wei /var/lib/mysql

这使我可以查看目录内部并查看我的文件,所以我认为自己正在取得进展.但是,一旦完成此操作,我便意识到,当我尝试在mysql中使用数据库时:

This allowed me to view inside the directory and see my files, so I thought I was making progress. However, once I had done this I realized that when I tried to USE the database in mysql:

USE securities_database;

我收到如下错误消息:

ERROR 1049 (42000): Unknown database 'securities_master'

我认为这与我之前使用chown有关.在通过进一步的stackoverflow搜索进行调查之后,我现在的印象是,我不应该轻易地从根目录中删除某些文件的根目录所有权,因为可能会发生坏事".我尝试通过以下方式恢复根所有权:

I believe this is related to my use of chown earlier. Upon looking into this with further stackoverflow searches, I'm now under the impression I shouldn't be willy nilly taking away root ownership of some files from root as "bad things can happen". I've tried to restore root ownership with:

sudo chown -R root /var/lib/mysql

AND/OR:

sudo chown -R root:root /var/lib/mysql

但是不幸的是,我似乎仍然收到相同的错误消息.

But unfortunately I seem to still get the same error message.

如果我的问题看起来如此基本,或者出现了菜鸟错误,我对此表示歉意,这里是Ubuntu,Linux和mysql的新手.谢谢.

I apologize if my question seems so basic, or such a rookie error, total newbie to Ubuntu, Linux and mysql here. Thanks.

推荐答案

/var/lib/mysql中所有内容的常规所有权为mysql:mysql.因此,您应该可以使用以下方法修复它:

The normal ownership of everything in /var/lib/mysql is mysql:mysql. So you should be able to fix it with:

sudo chown -R mysql:mysql /var/lib/mysql

这篇关于用于/var/lib/mysql的chown从根目录更改所有者,现在在mysql中出现错误1049(42000)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆