我全新安装了Ubuntu 19.10和Mysql 服务器 8.0.18-0ubuntu0.19.10.1
我尝试使用以下命令启动 mysql:
sudo mysqld --init-file=/home/da/dainit &
我有一个 init 文件/主页/da/dainit包含并尝试了各种选择,例如
ALTER USER 'root'@'localhost' IDENTIFIED BY 'abc';
或者
UPDATE mysql.user SET authentication_string = PASSWORD('p@ssw0rd')
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
(虽然我知道它不适用于 mysql 8.x)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root-password';
什么都没起作用。
初始化文件有如下错误消息:
2020-01-21T06:48:13.933707Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18-0ubuntu0.19.10.1) starting as process 8530
2020-01-21T06:48:14.430914Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-01-21T06:48:14.455683Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000029 - File '/home/da/dainit' not found (OS errno 13 - Permission denied)
2020-01-21T06:48:14.455730Z 0 [ERROR] [MY-010455] [Server] Failed to open the bootstrap file /home/da/dainit
2020-01-21T06:48:14.455742Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-01-21T06:48:15.513739Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18-0ubuntu0.19.10.1) (Ubuntu).
我已经应用了命令
sudo chown mysql:adm /home/da/dainit
得到错误:
2020-01-21T09:59:17.896016Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18-0ubuntu0.19.10.1) starting as process 5731
2020-01-21T09:59:18.441042Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-01-21T09:59:18.443337Z 0 [ERROR] [MY-010273] [Server] Could not create unix socket lock file /var/run/mysqld/mysqld.sock.lock.
2020-01-21T09:59:18.443715Z 0 [ERROR] [MY-010268] [Server] Unable to setup unix socket lock file.
2020-01-21T09:59:18.444373Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-01-21T09:59:19.473693Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18-0ubuntu0.19.10.1) (Ubuntu).
答案1
未找到文件‘/home/da/dainit’(OS errno 13 - 权限被拒绝
这应该很简单:该文件不属于您的 mysql 用户。Mysql 有自己的用户,并且要求您要访问的文件属于该用户。
sudo chown mysql:adm /home/da/dainit
可以修复它。(mysql:adm 是默认值;如果您更改了这些,请将其更改为您需要的)