Problem setting up mysql

Following the standard instructions available on the web I did
sudo apt install mysql-server
The messages then included

Setting up mysql-community-server (8.4.1-1ubuntu22.04) ...
Could not execute systemctl: at /usr/bin/deb-systemd-invoke line 142.
Could not execute systemctl: at /usr/bin/deb-systemd-invoke line 142.
Setting up mysql-server (8.4.1-1ubuntu22.04) ...

and I then got the following
% sudo systemctl start mysql.service
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details.

Help to fix this would be much appreciated

it tells you, did you try those?

1 Like

Yes, I looked at both but, probably due to my ignorance, I was not able to learn anything thereby. Here's what I got.

% sudo systemctl status mysql.service
[sudo] password for mm:
× mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: e>
Active: failed (Result: exit-code) since Mon 2024-07-01 12:46:04 BST; 49min >
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 423517 ExecStartPre=/usr/share/mysql-8.4/mysql-systemd-start pre (co>
Process: 423556 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 423556 (code=exited, status=1/FAILURE)
Status: "Components initialization successful"
CPU: 544ms

Jul 01 12:46:03 Bianchi6 systemd[1]: Starting MySQL Community Server...
Jul 01 12:46:04 Bianchi6 systemd[1]: mysql.service: Main process exited, code=exi>
Jul 01 12:46:04 Bianchi6 systemd[1]: mysql.service: Failed with result 'exit-code>
Jul 01 12:46:04 Bianchi6 systemd[1]: Failed to start MySQL Community Server.

The journalctl command gave a series of failure messages e.g.
Jul 01 12:46:04 Bianchi6 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: Enterprise open source support | Ubuntu
░░
░░ An ExecStart= process belonging to unit mysql.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.

can you point me to the "standard instructions on the web" so I can install mysql on a vm?

1 Like

here's a very basic install, https://ubuntu.com/server/docs/install-and-configure-a-mysql-server

1 Like

Tried that. The second command listed there gives me.
% sudo service mysql status
× mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor prese>
Active: failed (Result: exit-code) since Mon 2024-07-01 12:46:04 BST; 4h>
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 423517 ExecStartPre=/usr/share/mysql-8.4/mysql-systemd-start pre>
Process: 423556 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 423556 (code=exited, status=1/FAILURE)
Status: "Components initialization successful"
CPU: 544ms

Jul 01 12:46:03 Bianchi6 systemd[1]: Starting MySQL Community Server...
Jul 01 12:46:04 Bianchi6 systemd[1]: mysql.service: Main process exited, code>
Jul 01 12:46:04 Bianchi6 systemd[1]: mysql.service: Failed with result 'exit->
Jul 01 12:46:04 Bianchi6 systemd[1]: Failed to start MySQL Community Server.

I am wondering if the problem could be some sort of permissions issue.

just tried it on my vm, um24.04

mysqld is running as pid 4445
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /usr/lib/systemd/system/mysql.service.
Setting up mysql-server (8.0.37-0ubuntu0.24.04.1) ...
Processing triggers for man-db (2.12.0-4build2) ...
Processing triggers for libc-bin (2.39-0ubuntu8.2) ...

user@um24:~$ sudo service mysql status
● mysql.service - MySQL Community Server
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: active (running) since Mon 2024-07-01 09:28:21 MST; 10s ago
    Process: 4672 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 4693 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 9446)
     Memory: 365.4M (peak: 379.6M)
        CPU: 818ms
     CGroup: /system.slice/mysql.service
             └─4693 /usr/sbin/mysqld

Jul 01 09:28:21 um24 systemd[1]: Starting mysql.service - MySQL Community Server...
Jul 01 09:28:21 um24 systemd[1]: Started mysql.service - MySQL Community Server.
user@um24:~$
2 Likes

I noticed your dir is /usr/share/mysql-8.4/ but mine is /usr/share/mysql/

I think there is a conflict somewhere, I suggest you remove everything mysql and start again.

3 Likes

Good that it works for you, but I have no clue as to why it fails for me.

Hi, @mahmacc (Malcolm MacCallum) :slight_smile:

Following up to what @pavlos_kairis has also written, I've just tried to search the "mysql-server" package in a laptop computer running Ubuntu MATE 22.04.4 LTS ("Jammy Jellyfish") and the MySQL Server package available is 8.0.37 (and not 8.4.1):

$ apt search mysql-server
Sorting... Done
Full Text Search... Done
default-mysql-server/jammy,jammy 1.0.8 all
 MySQL database server binaries and system database setup (metapackage)

default-mysql-server-core/jammy,jammy 1.0.8 all
 MySQL database server binaries (metapackage)

mysql-server/jammy-updates,jammy-updates,jammy-security,jammy-security 8.0.37-0ubuntu0.22.04.3 all
 MySQL database server (metapackage depending on the latest version)

mysql-server-8.0/jammy-updates,jammy-security 8.0.37-0ubuntu0.22.04.3 amd64
 MySQL database server binaries and system database setup

mysql-server-core-8.0/jammy-updates,jammy-security 8.0.37-0ubuntu0.22.04.3 amd64
 MySQL database server binaries

Could you please tell us what was the specific tutorial / web page you followed to install "mysql-server" or, if don't remember what it was, then go through your command "history" to see what commands you used? Also, could you please run that apt search mysql-server command in that computer and include the output of that command in your reply? Thanks in advance :slight_smile:

3 Likes

I do not recall which site I took the steps from but more than one said the
same (NB I have linux ubuntu mate 22.04 and apache2 running so this was
done for the 3rd step of the LAMP stack) i.e. do
sudo apt update
sudo apt install mysql-server
and it was that second step that failed as reported in my opening message.

Looking at line 142 of /usr/bin/deb-systemd-invoke it appears that a call to
systemctl failed but I do not know enough about the software to see why.

Looking again, the mysql-server that appears in the list when I do
sudo synaptic
says it's 8.4.1-1ubuntu22.04. I could also try the mysql-server-8.0 listed
there which is 8.0.37-0ubuntu0.22.04.3. I could try removing the mysql-server
and starting again using the mysql-server-8.0 if that might help.

Use synaptic and remove ALL pkgs that match 'mysql'. It will remove those mysql-8.4.

then usual install ...

sudo apt update
sudo apt install mysql
sudo service mysql status

These are the pkgs I have in my VM 24.04

user@um24:~$ dpkg -l | grep mysql
ii  mysql-client-8.0                         8.0.37-0ubuntu0.24.04.1                  amd64        MySQL database client binaries
ii  mysql-client-core-8.0                    8.0.37-0ubuntu0.24.04.1                  amd64        MySQL database core client binaries
ii  mysql-common                             5.8+1.1.0build1                          all          MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-server                             8.0.37-0ubuntu0.24.04.1                  all          MySQL database server (metapackage depending on the latest version)
ii  mysql-server-8.0                         8.0.37-0ubuntu0.24.04.1                  amd64        MySQL database server binaries and system database setup
ii  mysql-server-core-8.0                    8.0.37-0ubuntu0.24.04.1                  amd64        MySQL database server binaries
user@um24:~$
3 Likes

Re your query, I got
% sudo apt search mysql-server
[sudo] password for mm:
Sorting... Done
Full Text Search... Done
default-mysql-server/jammy,jammy 1.0.8 all
MySQL database server binaries and system database setup (metapackage)

default-mysql-server-core/jammy,jammy 1.0.8 all
MySQL database server binaries (metapackage)

mysql-server/unknown,now 8.4.1-1ubuntu22.04 amd64 [installed]
MySQL Server meta package depending on latest version

mysql-server-8.0/jammy-updates,jammy-security 8.0.37-0ubuntu0.22.04.3 amd64 [residual-config]
MySQL database server binaries and system database setup

mysql-server-core-8.0/jammy-updates,jammy-security 8.0.37-0ubuntu0.22.04.3 amd64
MySQL database server binaries

this shows unknown distro instead of jammy, probably the conflict.

3 Likes

Hi again, @mahmacc :slight_smile:

I agree again with @pavlos_kairis, this regarding the following line in your "apt search mysql-server" output:

mysql-server/unknown,now 8.4.1-1ubuntu22.04 amd64 [installed]

You may want to check what software package repositories ("repos") are configured in that machine of yours. The following command should return that list:

grep ^[^#] /etc/apt/sources.list && for file in /etc/apt/sources.list.d/*; do grep ^[^#] $file; done | sort --unique 

My (untested!) suggestion would be similar to @pavlos_kairis (given you're NOT being able to start MySQL Server, I'm naturally assuming that you don't have any installed databases that you need to back up first):

1 - Remove (uninstall) the "offending" mysql-server package.

2 - Remove the "offending" MySQL 8.4 repository from your /etc/apt/sources.list file or from the associated file in the /etc/apt/sources.list.d directory, if that's the case.

3 - Run sudo apt update

4 - Install the mysql-server package:

sudo apt update  && sudo apt install mysql-server 

5 - Run again the apt search mysql-server command to make sure that the installed package versions are correct this time.

6 - Start the MySQL service:

sudo systemctl start mysql

7 - Check the status of the MySQL service:

sudo systemctl status mysql

I hope this helps :slight_smile:

2 Likes

That's essentially what I have done, but it still does not work. I now done an install that uses 8.0.37-0ubuntu0.22.04.3 and all seemed to go well until:


Installing new version of config file /etc/mysql/mysql.conf.d/mysqld.cnf ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf 
(my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
mysqld will log errors to /var/log/mysql/error.log
2024-07-02T15:52:02.211265Z 0 [ERROR] [MY-010946] [Server] Failed to start my
sqld daemon. Check mysqld error log.
Warning: Unable to start the server.
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /
lib/systemd/system/mysql.service.
Job for mysql.service failed because the control process exited with error co
de.
See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for 
details.

so I still cannot successfully start the server. It could be there's some lurking part
of the previous setup that has not been removed but I have no idea how to identify
that.

You're really not having an easy time with that MySQL installation, @mahmacc :frowning: Try to run the following commands, based on the suggestions of that output, to see if we can find the error(s):

cat /var/log/mysql/error.log

systemctl status mysql --no-pager

journalctl -xeu mysql  --no-pager
1 Like

I had a fresh try, first using synaptic to completely remove the mysql entries. Then did the apt update and install mysqi-server. No joy. I then followed the suggestions in ricmarques post on 2 July. I have saved the outputs. I do not see how to attach that here but I could append - it's a bit long

You can send files using this trick ...

cat /var/log/syslog | nc termbin.com 9999

it will give you a link which you can post here. Post what Ric asked.

(BTW, I created a UM22.04 VM, installed mysql-server without errors so I dont know what is going on with your system)

1 Like

The link is https://termbin.com/o7ss to a zip file containing the outputs Ric asked for.