I'm running Ubuntu 20.04.6 on WSL, and am having trouble starting mysql-server using the command sudo service mysql start
, which returns mysqld: unrecognized service
(the same result with mysqld
).
For some background, this morning I accidentally upgraded rather than updated my environment, including MySQL to a version my editor (and others I tried) don't currently support (8.0.35). I attempted to downgrade to an earlier version, but now no matter what, I'm having issues with getting MySQL up and running again. I've been trawling through posts on here and Stackoverflow, but not had any success as of yet.
Whether it's a permissions problem, or a configuration problem I'm unsure, but please see some of the latest steps I've taken below:
Uninstalled with:sudo apt-get remove --purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql* /var/run/mysqld
And to clean up:sudo apt-get autoremove sudo apt-get autoclean
sudo apt-get update
Tried installing with both older versions and the latest versions of MySQL:sudo apt-get install mysql-server-8.0=8.0.19-0ubuntu5 mysql-client-8.0=8.0.19-0ubuntu5
sudo sudo apt-get install mysql-server mysql-client
.
After this as mentioned before, when trying sudo service mysql start
I get mysqld: unrecognized service
.
In case it just needed registering, I tried registering mysql and mysqld via systemctl, which didn't work, along with creating a custom service in /etc/init.d/ called mysql_custom, also to no avail.
Running mysql --version
returns: "Ver 8.0.35 for Linux on x86_64 (MySQL Community Server - GPL)", indicating it's at least installed, and running mysql
and mysqld
returns the following errors respectfully:
mysql: 2023-12-31T18:12:37.448254Z 0 [Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2023-12-31T18:12:37.448300Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.35) starting as process 3855
2023-12-31T18:12:37.450166Z 0 [Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2023-12-31T18:12:37.450172Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2023-12-31T18:12:37.450185Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to '/var/lib/mysql/' (OS errno: 13 - Permission denied)
2023-12-31T18:12:37.450245Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-12-31T18:12:37.450320Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.35) MySQL Community Server - GPL.mysqld: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
From here I'm really at a total loss for where to go next, so really hoping somebody on here has been through this or something similar before that can help. If you need any more information, or need me to try running any commands, please let me know.