mariadb ERROR 2002 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)

By | 25 8 月, 2020

Windows上安装的绿色版MariaDB.

  • mysqld: 启动MariDB
  • mysql –uroot: 连接数据库

突然发现,mysql –uroot不成功,显示“ERROR 2002 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)”。

查看Log

Log文件在${MARIA_DB_DIR}/data/${PC_NAME}.err,删除这个文件,然后重新执行mysqld,失败了会重新生成这个文件。文件内容

InnoDB: using atomic writes.
2020-08-25 17:43:44 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2020-08-25 17:43:44 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2020-08-25 17:43:44 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-08-25 17:43:44 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-08-25 17:43:44 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-08-25 17:43:44 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2020-08-25 17:43:44 0 [ERROR] Aborting

根据提示,Google搜索“InnoDB: The innodb_system data file ‘ibdata1’ must be writable”,发现${MARIA_DB_DIR}/data/这个目录,以及里面的文件需要写权限。

解决方法

我用的windows系统,找到data文件夹,右键 –> Properties,在弹出的窗口里,把”Read-only (Only applies to files in folder)”前面的勾去掉即可。

image