Score:0

how to start mysql server on Ubuntu 20.04

in flag

I have Ubuntu installed via WSL 2 like so: Ubuntu 20.04.4 LTS (GNU/Linux 5.10.102.1-microsoft-standard-WSL2 x86_64)

I'm trying to install mysql-server with this command, 'sudo apt install mysql-server'

(https://ubuntu.com/server/docs/databases-mysql)

I get it installed with

mysql --version
mysql  Ver 8.0.31-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

but it does not start after that.

(base) bluetail14@LAPTOP-28BMMQV7:~$ sudo service mysql start
 * Starting MySQL database server mysqld

(base) bluetail14@LAPTOP-28BMMQV7:~$ sudo service mysql restart                                                  [ OK ]
 * Starting MySQL database server mysqld                                                                                su: warning: cannot change directory to /nonexistent: No such file or directory

I have tried a set of these commands:

this one is to change the home directory.

(base) bluetail14@LAPTOP-28BMMQV7:~$ sudo usermod -d /var/lib/mysql/ mysql
usermod: user mysql is currently used by process 3622

(base) bluetail14@LAPTOP-28BMMQV7:~$ sudo systemctl stop mysql.service
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
(base) bluetail14@LAPTOP-28BMMQV7:~$ sudo usermod -d /var/lib/mysql/ mysql
usermod: user mysql is currently used by process 3622
(base) bluetail14@LAPTOP-28BMMQV7:~$ sudo systemctl start mysql.service
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

So it looks like I need to configure a home directory from nonexistent or something else? how can I set it up correctly?

uz flag
Jos
Your `mysql` system seems to be running. As you're working in WSL, you can't use `systemd` commands such as `systemctl`. Instead, use `sudo service mysql stop` (and start, and restart, and status) for managing MySQL. Please don't change the default location of MySQL directories unless you know very well what you are doing.
Bluetail avatar
in flag
thank you. it helps. I used 'sudo service mysql status' and it does not throw any errors.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.