开发和自学的新手(感谢 Covid)所以这可能很草率:(对不起...
让我首先说我不关心数据库中的数据 - 如果删除它并重新开始更容易,我对此很好(不知道该怎么做,但我可以它)
不知道是什么导致了这个问题,但有一天 MySQL 无法启动。使用服务 MySQL Restart 修复了它......两天后它再次发生此错误
sarcasticsnark@LB-HP-LT:~/Projects/FMS$ sudo service mysql start
* Starting MySQL database server mysqld
su: warning: cannot change directory to /nonexistent: No such file or directory
我尝试了一些“解决方案”我的文件现在看起来像这样,我不确定我是否获得了正确的权限。
sarcasticsnark@LB-HP-LT:/var/lib$ ls
AccountsService command-not-found fwupd logrotate mysql mysql2, private systemd ucf usbutils
PackageKit dbus git man-db mysql-files pam python tpm unattended-upgrades vim
apt dhcp initramfs-tools mecab mysql-keyring plymouth snapd ubuntu-advantage update-manager
boltd dpkg landscape misc mysql-upgrade polkit-1 sudo ubuntu-release-upgrader update-notifier
sarcasticsnark@LB-HP-LT:/var/lib$ cd mysql
sarcasticsnark@LB-HP-LT:/var/lib/mysql$ ls
'#ib_16384_0.dblwr' TestingGround_development binlog.000009 binlog.000013 binlog.000017 client-cert.pem mysql.ibd server-cert.pem undo_002
'#ib_16384_1.dblwr' TestingGround_test binlog.000010 binlog.000014 binlog.index client-key.pem performance_schema server-key.pem
'#innodb_temp' auto.cnf binlog.000011 binlog.000015 ca-key.pem debian-5.7.flag private_key.pem sys
FMS_development binlog.000008 binlog.000012 binlog.000016 ca.pem mysql public_key.pem undo_001
2020-07-20T02:29:41.520132Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 4096 (requested 8161)
2020-07-20T02:29:41.520141Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 1967 (requested 4000)
2020-07-20T02:29:41.520561Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.20-0ubuntu0.20.04.1) initializing of server in progress as process 2570
2020-07-20T02:29:41.522888Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2020-07-20T02:29:41.522921Z 0 [ERROR] [MY-010187] [Server] Could not open file '/var/log/mysql/error.log' for error logging: Permission denied
2020-07-20T02:29:41.523139Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2020-07-20T02:29:41.523187Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-07-20T02:29:41.523313Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20-0ubuntu0.20.04.1) (Ubuntu).
/var/log/mysql - 确实存在,它的权限是:-rw-r----- 1 mysql adm 62273 Jul 19 19:36 error.log
这是 mysql/error.log2020-07-20T01:50:07.952988Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2020-07-20T01:50:07.986416Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2020-07-20T01:50:08.000603Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8161)
2020-07-20T01:50:08.000610Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 431 (requested 4000)
2020-07-20T01:50:08.262922Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20-0ubuntu0.20.04.1) starting as process 1608
2020-07-20T01:50:08.281623Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-07-20T01:50:08.322464Z 1 [ERROR] [MY-012592] [InnoDB] Operating system error number 2 in a file operation.
2020-07-20T01:50:08.322818Z 1 [ERROR] [MY-012593] [InnoDB] The error means the system cannot find the path specified.
2020-07-20T01:50:08.322947Z 1 [ERROR] [MY-012594] [InnoDB] If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2020-07-20T01:50:08.323017Z 1 [ERROR] [MY-012646] [InnoDB] File ./ibdata1: 'open' returned OS error 71. Cannot continue operation
2020-07-20T01:50:08.323105Z 1 [ERROR] [MY-012981] [InnoDB] Cannot continue operation.
2020-07-20T01:50:08.972320Z mysqld_safe mysqld from pid file /var/lib/mysql/LB-HP-LT.pid ended
以及/var/lib/mysql 的权限sarcasticsnark@LB-HP-LT:/var/lib/mysql$ cd /var/lib
sarcasticsnark@LB-HP-LT:/var/lib$ sudo ls -l mysql
[sudo] password for sarcasticsnark:
total 58048
-rw-r----- 1 mysql mysql 196608 Jul 19 16:34 '#ib_16384_0.dblwr'
-rw-r----- 1 mysql mysql 8585216 Jul 11 22:54 '#ib_16384_1.dblwr'
drwxr-x--- 2 mysql mysql 4096 Jul 19 16:35 '#innodb_temp'
drwxr-x--- 2 mysql mysql 4096 Jul 15 18:06 FMS_development
drwxr-x--- 2 mysql mysql 4096 Jun 20 09:04 TestingGround_development
drwxr-x--- 2 mysql mysql 4096 Jun 22 20:07 TestingGround_test
-rw-r----- 1 mysql mysql 56 Jun 10 17:43 auto.cnf
-rw-r----- 1 mysql mysql 210461 Jul 15 17:01 binlog.000008
-rw-r----- 1 mysql mysql 179 Jul 15 17:30 binlog.000009
-rw-r----- 1 mysql mysql 156 Jul 15 17:43 binlog.000010
-rw-r----- 1 mysql mysql 2798 Jul 19 15:55 binlog.000011
-rw-r----- 1 mysql mysql 179 Jul 19 15:56 binlog.000012
-rw-r----- 1 mysql mysql 179 Jul 19 16:11 binlog.000013
-rw-r----- 1 mysql mysql 179 Jul 19 16:25 binlog.000014
-rw-r----- 1 mysql mysql 179 Jul 19 16:27 binlog.000015
-rw-r----- 1 mysql mysql 179 Jul 19 16:27 binlog.000016
-rw-r----- 1 mysql mysql 179 Jul 19 16:34 binlog.000017
-rw-r----- 1 mysql mysql 160 Jul 19 16:27 binlog.index
-rw------- 1 mysql mysql 1680 Jun 10 17:43 ca-key.pem
-rw-r--r-- 1 mysql mysql 1112 Jun 10 17:43 ca.pem
-rw-r--r-- 1 mysql mysql 1112 Jun 10 17:43 client-cert.pem
-rw------- 1 mysql mysql 1680 Jun 10 17:43 client-key.pem
-rw-r--r-- 1 mysql mysql 0 Jun 12 15:54 debian-5.7.flag
drwxr-xr-x 2 mysql mysql 4096 Jun 10 17:43 mysql
-rw-r----- 1 mysql mysql 25165824 Jul 19 16:28 mysql.ibd
drwxr-x--- 2 mysql mysql 4096 Jun 10 17:43 performance_schema
-rw------- 1 mysql mysql 1680 Jun 10 17:43 private_key.pem
-rw-r--r-- 1 mysql mysql 452 Jun 10 17:43 public_key.pem
-rw-r--r-- 1 mysql mysql 1112 Jun 10 17:43 server-cert.pem
-rw------- 1 mysql mysql 1676 Jun 10 17:43 server-key.pem
drwxr-x--- 2 mysql mysql 4096 Jun 10 17:43 sys
-rw-r----- 1 mysql mysql 12582912 Jul 19 16:34 undo_001
-rw-r----- 1 mysql mysql 12582912 Jul 19 16:34 undo_002
最佳答案
mysql 用户正在寻找 主目录 ,这似乎没有被分配。
为此,您可以执行:
sudo systemctl stop mysql.service
sudo usermod -d /var/lib/mysql/ mysql
sudo systemctl start mysql.service
或者sudo service mysql stop
sudo usermod -d /var/lib/mysql/ mysql
sudo service mysql start
Based on a response found here
关于MySQL 无法启动 - 错误 : su: warning: cannot change directory to/nonexistent: No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62987154/