mysql 启动报错:read-only file system
时间: 2024-10-10 16:15:23 浏览: 134
MySQL启动时报"read-only file system"错误通常是由于操作系统将MySQL的数据文件所在的文件系统设置为了只读模式。这可能是出于安全原因,比如备份策略或者防止意外修改数据。当尝试在一个只读文件系统上创建、删除或更改数据库文件时,MySQL会遇到这个问题。
解决这种问题通常有以下几个步骤:
1. **临时改变权限**:你可以通过命令行切换到root用户并挂载只读文件系统为可写,但这不是长期解决方案,因为重启后可能会再次变回只读。
```sh
sudo mount -o remount,rw /mount_point/
```
2. **修改配置**:如果可能,检查my.cnf配置文件,确认data目录是否设置为只读,如果是的话,去掉只读标志。
```ini
[mysqld]
datadir=/path/to/data
```
3. **移除只读属性**:如果数据目录本身就是只读,需要解除其只读状态,然后移动或复制数据到一个新的非只读位置。
4. **恢复或重建数据**:如果无法临时修改,可能需要从备份恢复数据,或者在新的磁盘上安装MySQL,并迁移数据。
5. **联系管理员**:如果是服务器级别的问题,最好联系系统的管理员来处理这个设置,因为他们可能有特定的理由让文件系统保持只读。
相关问题
root@DESKTOP-0CU081I:/# mysqld --default_authentication_plugin=mysql_native_password mysqld: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored. 2023-06-05T10:03:19.501899Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead. 2023-06-05T10:03:19.501927Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.33-0ubuntu0.20.04.2) starting as process 394 2023-06-05T10:03:19.503362Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root! 2023-06-05T10:03:19.503414Z 0 [ERROR] [MY-010119] [Server] Aborting 2023-06-05T10:03:19.503500Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.33-0ubuntu0.20.04.2) (Ubuntu)如何解决
这是一个关于 MySQL 的错误信息,提示你不能使用 root 用户来启动 MySQL 服务。解决方法是以非 root 用户身份启动 MySQL 服务。
可以使用以下命令来启动 MySQL 服务:
```
sudo systemctl start mysql
```
如果你已经以 root 用户身份启动了 MySQL 服务,可以使用以下命令来停止 MySQL 服务:
```
sudo systemctl stop mysql
```
然后再以非 root 用户身份启动 MySQL 服务。
root@DESKTOP-0CU081I:/# sudo mysqld --default_authentication_plugin=mysql_native_password mysqld: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored. 2023-06-05T10:01:47.364773Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead. 2023-06-05T10:01:47.364802Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.33-0ubuntu0.20.04.2) starting as process 392 2023-06-05T10:01:47.366321Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root! 2023-06-05T10:01:47.366408Z 0 [ERROR] [MY-010119] [Server] Aborting 2023-06-05T10:01:47.366507Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.33-0ubuntu0.20.04.2) (Ubuntu).
在上述命令中,出现了以下几个问题:
1. `default_authentication_plugin` 已经被标记为过时的参数,将来会被移除,应该使用 `authentication_policy` 参数来替代。
2. 该命令使用了 `sudo` 来以 root 权限运行 `mysqld`,但是 MySQL 官方强烈建议不要使用 root 用户来运行 `mysqld`。
3. 出现了一个致命错误,提示需要阅读 MySQL 手册中的 "Security" 部分来了解如何以 root 用户身份运行 `mysqld`。
因此,建议使用以下命令来启动 `mysqld`:
```
sudo systemctl start mysql
```
这将使用 MySQL 8.0 的默认配置启动 MySQL 服务。如果你需要指定 `authentication_policy` 参数,可以在 MySQL 配置文件中进行设置,例如在 `/etc/mysql/mysql.conf.d/mysqld.cnf` 文件中添加以下内容:
```
[mysqld]
authentication_policy = mysql_native_password
```
然后重新启动 MySQL 服务:
```
sudo systemctl restart mysql
```
这样就可以使用 `mysql_native_password` 认证插件来运行 MySQL 了。
阅读全文
相关推荐















