ERROR: got error when setting up GCP MySQL server - mysql

Here is my steps that can replicate:
Compute Engine Creation:
1.select F1-Micro instance.
2.Select Ubuntu 20.04 LTS Minimal.
Install:
$sudo apt-get update
$sudo apt-get install mysql-server
My question is how can I get no error when setting up MySQL server in GCP?
Here is the error:
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-pre) since Fri 2021-01-29 20:58:52 UTC; 3s ago
Cntrl PID: 2338 (mysql-systemd-s)
Tasks: 1 (limit: 682)
Memory: 1.7M
CGroup: /system.slice/mysql.service
├─2338 /bin/bash /usr/share/mysql/mysql-systemd-start pre
├─2356 /bin/bash /usr/share/mysql/mysql-systemd-start pre
├─2357 /bin/bash /usr/share/mysql/mysql-systemd-start pre
├─2358 [my_print_defaul]
├─2359 sed -n s/^--datadir=//p
└─2360 tail -n 1
Jan 29 20:58:49 instance-1 systemd[1]: mysql.service: Killing process 2233 (mysqld) with signal SIGKILL.
Jan 29 20:58:51 instance-1 systemd[1]: mysql.service: Main process exited, code=killed, status=9/KILL
Jan 29 20:58:51 instance-1 systemd[1]: mysql.service: Failed with result 'timeout'.
Jan 29 20:58:51 instance-1 systemd[1]: Failed to start MySQL Community Server.
Jan 29 20:58:52 instance-1 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 1.
Jan 29 20:58:52 instance-1 systemd[1]: Stopped MySQL Community Server.
Jan 29 20:58:52 instance-1 systemd[1]: Starting MySQL Community Server...
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Setting up libcgi-pm-perl (4.46-1) ...
Setting up libhtml-template-perl (2.97-1) ...
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-8.0; however:
Package mysql-server-8.0 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Setting up libcgi-fast-perl (1:2.15-1) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Processin
g triggers for systemd (245.4-4ubuntu3.4) ...
Processing triggers for libc-bin (2.31-0ubuntu9.1) ...
Errors were encountered while processing:
mysql-server-8.0
mysql-server```

Related

Problems installing MySQL on Ubuntu 22.04.1

I am trying to install MySQL in Ubuntu server 22.04.1 whit but I keep geting this error:
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.
invoke-rc.d: initscript mysql, action "start" failed.
* mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2022-08-17 22:11:24 UTC; 9ms ago
Process: 1461 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 1469 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 1469 (code=exited, status=1/FAILURE)
Status: "Server shutdown complete"
Error: 22 (Invalid argument)
CPU: 654ms
Aug 17 22:11:24 SQL systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Aug 17 22:11:24 SQL systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 17 22:11:24 SQL systemd[1]: Failed to start MySQL Community Server.
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-8.0; however:
Package mysql-server-8.0 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Setting up libcgi-fast-perl (1:2.15-1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Errors were encountered while processing:
mysql-server-8.0
mysql-server
After reading this:
Problems installing MySQL on Ubuntu 20.04
dpkg: error processing package mysql-server (dependency problems)?
I've tried this:
sudo systemctl stop mysql
sudo apt clean
sudo apt purge mysql*
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
sudo apt autoremove
sudo apt autoclean
sudo apt update
sudo apt dist-upgrade
sudo apt install -f
sudo apt install mysql-server
But I'm still getting the same error
Then I read this:
I did not manage to install mysql on Ubuntu completely
So I tried
sudo mysql_secure_installation
but then I got this error:
Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I am running Ubuntu Server 22.04.1 LTS on a LXC with 4GB of RAM and one CPU core
Edit:
sudo journalctl -u mysql.service -n 60 outputs:
Aug 17 22:24:46 SQL systemd[1]: Starting MySQL Community Server...
Aug 17 22:24:47 SQL systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Aug 17 22:24:47 SQL systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 17 22:24:47 SQL systemd[1]: Failed to start MySQL Community Server.
Aug 17 22:24:48 SQL systemd[1]: mysql.service: Scheduled restart job, restart counter is at 27.

MySQL "start" fails in ubuntu 20.04

I try to run the command:
sudo systemctl start mysql
And receive the following message:
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
Then when i type:
sudo systemctl status mysql.service
I get the following message:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2021-03-02 11:32:34 IST; 58s ago
Process: 3383 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Mar 02 11:32:34 avivilloz systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Mar 02 11:32:34 avivilloz systemd[1]: Stopped MySQL Community Server.
Mar 02 11:32:34 avivilloz systemd[1]: mysql.service: Start request repeated too quickly.
Mar 02 11:32:34 avivilloz systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 02 11:32:34 avivilloz systemd[1]: Failed to start MySQL Community Server.
I searched for hours and couldn't come with a solution... does anyone know what could be the error?
The only thing i did before that was to install mysql-server with the command:
sudo apt-get install mysql-server
I tried installing and reinstalling, updating and upgrading ubuntu, i'm not sure if this would help.
Thanks in advance!
UPDATE:
I just checked, and don't have the /var/lib/mysql directory in my computer. But i failed to get it by reinstalling mysql server/client.
I fixed by "purging" every file related to mysql and reinstalling mysql-server:
sudo apt-get purge mysql-server mysql-client mysql-common
sudo apt-get install mysql-server
In my case the issue is raised b.c the server storage is full.
removing some logs and files solved and then restarting it solved the problem.

apt upgrade mysqlserver freezes and will not upgrade (ubuntu server 20.04)

I had to kill the session and then the databases are inaccessible until I reboot the server.
When I log back in and issue ‘apt upgrade’ i get the following error.
E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.
I run ‘dpkg --configure -a’ and get the following and then it just freezes
Setting up mysql-server-8.0 (8.0.22-0ubuntu0.20.04.3) ...
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 86150
On another tty
journalctl -xe gives this when the upgrade freezes.
-- The unit mysql.service has successfully entered the 'dead' state.
Jan 13 22:18:12 arpradio systemd[1]: Stopped MySQL Community Server.
-- Subject: A stop job for unit mysql.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A stop job for unit mysql.service has finished.
--
-- The job identifier is 582 and the job result is done.
Jan 13 22:18:13 arpradio audit[6057]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/usr/sbin/mysqld" pid>
Jan 13 22:18:13 arpradio kernel: audit: type=1400 audit(1610572693.036:16): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="uncon>
When I reboot and login mysqld is running
I have tried the following.
# cp -r /etc/mysql /etc/mysql_old
# apt autoremove
E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.
# dpkg --configure -a
Setting up mysql-server-8.0 (8.0.22-0ubuntu0.20.04.3) ...
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 7451
And we are back here with the freeze.
If I check the mysql processes I find no process 7451 but this is the output.
# ps aux | grep mysql
root 1679 0.0 0.0 8644 4688 ? Ssl 22:23 0:00 dockerize -template /tmp/db.cnf.tmpl:/etc/mysql/conf.d/db.cnf /usr/local/bin/docker-entrypoint.sh mysqld
systemd+ 2526 0.3 0.1 2446780 99836 ? Sl 22:23 0:03 mysqld
root 7370 0.3 0.0 27940 19836 pts/0 S+ 22:38 0:00 /usr/bin/perl -w /usr/share/debconf/frontend /var/lib/dpkg/info/mysql-server-8.0.postinst configure 8.0.22-0ubuntu0.20.04.2
root 7379 0.0 0.0 9756 3772 pts/0 S+ 22:38 0:00 /bin/bash /var/lib/dpkg/info/mysql-server-8.0.postinst configure 8.0.22-0ubuntu0.20.04.2
mysql 7657 1.9 0.5 1869164 358336 pts/0 Sl+ 22:39 0:01 mysqld --user=mysql --init-file=/var/lib/mysql-files/tmp.gQukBE7GtT --socket=/tmp/tmp.KUFQmDDseF/mysqld.sock --pid-file=/tmp/tmp.KUFQmDDseF/mysqld.pid
root 7759 0.0 0.0 9032 724 pts/1 S+ 22:39 0:00 grep --color=auto mysql
I checked the status of mysql.service
# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Wed 2021-01-13 22:38:59 CET; 17min ago
Process: 649 ExecStart=/usr/sbin/mysqld (code=exited, status=0/SUCCESS)
Main PID: 649 (code=exited, status=0/SUCCESS)
Status: "Server shutdown complete"
Jan 13 22:21:43 arpradio systemd[1]: Starting MySQL Community Server...
Jan 13 22:21:45 arpradio systemd[1]: Started MySQL Community Server.
Jan 13 22:38:57 arpradio systemd[1]: Stopping MySQL Community Server...
Jan 13 22:38:59 arpradio systemd[1]: mysql.service: Succeeded.
Jan 13 22:38:59 arpradio systemd[1]: Stopped MySQL Community Server.
I fixed it, what I did was while the upgrade was hanging I ran
apt update && apt upgrade
on another tty and it upgraded everything, rebooted, I checked again after reboot and everything looks good.
# apt update
Hit:1 http://asi-fs-n.contabo.net/ubuntu focal InRelease
Hit:2 http://asi-fs-n.contabo.net/ubuntu focal-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:4 https://download.docker.com/linux/ubuntu focal InRelease
Hit:5 http://asi-fs-n.contabo.net/ubuntu focal-backports InRelease
Get:6 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Fetched 109 kB in 1s (112 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
root#arpradio:~# apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root#arpradio:~# ps aux | grep mysql
mysql 657 1.2 0.6 2067208 378684 ? Ssl 23:09 0:02 /usr/sbin/mysqld
root 2148 0.1 0.0 9796 4784 ? Ssl 23:11 0:00 dockerize -template /tmp/db.cnf.tmpl:/etc/mysql/conf.d/db.cnf /usr/local/bin/docker-entrypoint.sh mysqld
systemd+ 2930 0.8 0.1 2380944 99508 ? Sl 23:11 0:00 mysqld
root 5507 0.0 0.0 9032 732 pts/0 S+ 23:12 0:00 grep --color=auto mysql
root#arpradio:~# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-01-13 23:09:06 CET; 3min 26s ago
Process: 560 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 657 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 72284)
Memory: 419.9M
CGroup: /system.slice/mysql.service
└─657 /usr/sbin/mysqld
Jan 13 23:09:04 arpradio systemd[1]: Starting MySQL Community Server...
Jan 13 23:09:06 arpradio systemd[1]: Started MySQL Community Server.

Can't start mysql server after updating Ubuntu 18.4

first i have tried to uninstall both of them
root#thaali:/etc/mysql# sudo apt-get remove --purge mysql*
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mysql.cnf
E: Couldn't find any package by glob 'mysql.cnf'
E: Couldn't find any package by regex 'mysql.cnf'
E: Unable to locate package mysql.conf.d
E: Couldn't find any package by glob 'mysql.conf.d'
E: Couldn't find any package by regex 'mysql.conf.d'
Then i have tried to install them
root#thaali:/etc/mysql# sudo apt-get install mysql-server mysql-client
Reading package lists... Done
Building dependency tree... 50%
Building dependency tree
Reading state information... Done
mysql-client is already the newest version (5.7.26-0ubuntu0.19.04.1).
mysql-server is already the newest version (5.7.26-0ubuntu0.19.04.1).
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.
This is what happen when i tried to restart
root#thaali:/etc/mysql# sudo service mysql start
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
This is what happened when i try to systemctl
root#thaali:/etc/mysql# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-05-29 22:07:43 +0530; 6min ago
Process: 21283 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILURE
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Failed with result 'exit-code'.
මැයි 29 22:07:43 thaali systemd[1]: Failed to start MySQL Community Server.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Service RestartSec=100ms expired, scheduling restart.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
මැයි 29 22:07:43 thaali systemd[1]: Stopped MySQL Community Server.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Start request repeated too quickly.
මැයි 29 22:07:43 thaali systemd[1]: mysql.service: Failed with result 'exit-code'.
මැයි 29 22:07:43 thaali systemd[1]: Failed to start MySQL Community Server.
This is the error that's throw me when i tried to connect
root#thaali:/etc/mysql# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Can any one please help me to solve this and i have seen in some places i have edit etc/my.cnf to fix this in my case i don't have such a file
This one is really weird for I was not dist upgrading. One day it just didn't work.
When I tried journalctl -xe I got this
...
Oct 05 08:51:26 <servername> mysql-systemd-start[10914]: ERROR: Unable to start MySQL server:
Oct 05 08:51:26 <servername> mysql-systemd-start[10914]: mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
...
I fixed it by doing this:
sudo mkdir /var/lib/mysql-files
sudo chown -R mysql:mysql /var/lib/mysql-files/
sudo chmod 700 /var/lib/mysql-files/
sudo service mysql restart
Restarting the service didn't actually fix all problems I was having so I ended with rebooting the machine.

Unable to install mysql-server on ubuntu 16.04

This is the terminal output coming when i am trying to install the mysql-server using the command -
sudo apt-get install mysql-server
Terminal o/p
Setting up mysql-community-server (5.7.18-1ubuntu16.04) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld at line 7: Could not open 'abstractions/mysql'
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2017-06-12 14:23:11 IST; 7ms ago
Process: 26677 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 26612 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 23756 (code=exited, status=1/FAILURE)
Jun 12 14:23:06 prat14k systemd[1]: Starting MySQL Community Server...
Jun 12 14:23:07 prat14k mysql-systemd-start[26612]: AppArmor parser error for...
Jun 12 14:23:07 prat14k mysqld[26677]: Initialization of mysqld failed: 0
Jun 12 14:23:07 prat14k systemd[1]: mysql.service: Control process exited, ...=1
Jun 12 14:23:11 prat14k systemd[1]: Failed to start MySQL Community Server.
Jun 12 14:23:11 prat14k systemd[1]: mysql.service: Unit entered failed state.
Jun 12 14:23:11 prat14k systemd[1]: mysql.service: Failed with result 'exit...'.
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package mysql-community-server (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-community-server (= 5.7.18-1ubuntu16.04); however:
Package mysql-community-server is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.23-0ubuntu7) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for systemd (229-4ubuntu17) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
mysql-community-server
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
i have tried about 5 times just removing,purging and all other commands, but cannot get it done.
also,
systemctl mysql status
is showing
AppArmor parser error for /etc
Please help
Try removing apparmor package:
sudo apt purge apparmor
and then re-attempt the installation with mysql-common package:
sudo apt install mysql-common mysql-server