Mysql Problem
Mysql Problem
At first, I wanted to install Jaxws, however the system recommended me doing `apt
--fix-broken install` because of an error. The mysql went conflict and dependencies
problem, so I tried to **clean uninstall** by doing this.
(Anyway, sorry for bad timestamp. By the time writing this, I also did some changes
so that I think it would make easier to figure out what's going on)
1. Show dpkg list for MySQL and MariaDB (empty already on this log), then remove
each of them
```
emp10@EMP10:~$ dpkg -l | grep mariadb
```
2. Purge MySQL packages and remove mysql folders
```
emp10@EMP10:~$ sudo apt purge mysql-server mysql-client mysql-common mysql-server-
core-* mysql-client-core-*
emp10@EMP10:~$ sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
emp10@EMP10:~$ sudo apt autoremove
emp10@EMP10:~$ sudo apt autoclean
```
3. Install MySQL server
```
emp10@EMP10:~$ sudo apt install mysql-server
...
done!
update-alternatives: using /var/lib/mecab/dic/ipadic-utf8 to provide
/var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
Setting up mysql-server-8.0 (8.0.31-0ubuntu0.20.04.2) ...
update-alternatives: warning: forcing reinstallation of alternative
/etc/mysql/mysql.cnf because link group my.cnf is broken
update-alternatives: warning: not replacing /etc/mysql/my.cnf with a link
Renaming removed key_buffer and myisam-recover options (if present)
mysqld: Can't get stat of '/etc/mysql/mariadb.cnf' (OS errno 2 - No such file or
directory)
mysqld: [ERROR] Stopped processing the 'include' directive in file
/etc/mysql/my.cnf at line 187.
mysqld will log errors to /var/lib/mysql/EMP10.err
2022-12-01T03:09:34.628510Z 0 [ERROR] [MY-010946] [Server] Failed to start mysqld
daemon. Check mysqld error log.
Warning: Unable to start the server.
Setting up mysql-server (8.0.31-0ubuntu0.20.04.2) ...
Processing triggers for systemd (245.4-4ubuntu3.19) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
```
4. Check MySQL status
```
emp10@EMP10:~$ sudo service mysql status
```
5. Enable mysql.service load and restart MySQL service
```
emp10@EMP10:~$ sudo systemctl enable mysql
```
---
**What I also tried (debugging)**
1. Create empty `/etc/mysql/mariadb.cnf`
```
/etc/mysql/mariadb.cnf
```
2. Run `sudo systemctl status mysql.service` again (3 times, the logs are
different)
```
emp10@EMP10:~$ sudo systemctl status mysql.service
```
3. For `journalctl -xe` error (I think for mysql.components error), I comments some
lines on `/etc/mysql/my.cnf`
(based on
[https://github.com/gitpod-io/gitpod/issues/1399](https://www.stackoverflow.com/))
```
#query_cache_limit = 128K
#query_cache_size = 64M
#expire_logs_days = 10
#max_binlog_size = 100M
```
```
emp10@EMP10:~$ 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.
```
5. See `systemctl status mysql.service` and `journalctl -xe`
```
emp10@EMP10:~$ systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:
enabled)
Active: activating (start-pre) since Thu 2022-12-01 11:26:57 WIB; 50ms ago
Cntrl PID: 215656 (mysql-systemd-s)
Tasks: 3 (limit: 6878)
Memory: 11.7M
CGroup: /system.slice/mysql.service
├─215656 /bin/bash /usr/share/mysql/mysql-systemd-start pre
├─215662 /bin/bash /usr/share/mysql/mysql-systemd-start pre
└─215663 mysqld --verbose --help --innodb-read-only
```
```
emp10@EMP10:~$ journalctl -xe
Des 01 11:27:51 EMP10 mysqld[215927]: 2022-12-01T04:27:51.916188Z 0 [System] [MY-
010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31-
0ubuntu0.20.04.2) (Ubuntu).
Des 01 11:27:51 EMP10 systemd[1]: mysql.service: Main process exited, code=exited,
status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit mysql.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Des 01 11:27:51 EMP10 systemd[1]: mysql.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit mysql.service has entered the 'failed' state with result 'exit-code'.
Des 01 11:27:51 EMP10 systemd[1]: Failed to start MySQL Community Server.
-- Subject: A start job for unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mysql.service has finished with a failure.
--
-- The job identifier is 300159 and the job result is failed.
Des 01 11:27:52 EMP10 systemd[1]: mysql.service: Scheduled restart job, restart
counter is at 495.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Automatic restarting of the unit mysql.service has been scheduled, as the result
for
-- the configured Restart= setting for the unit.
Des 01 11:27:52 EMP10 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 300244 and the job result is done.
Des 01 11:27:52 EMP10 systemd[1]: Starting MySQL Community Server...
-- Subject: A start job for unit mysql.service has begun execution
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mysql.service has begun execution.
--
-- The job identifier is 300244.
Des 01 11:27:52 EMP10 mysqld[215978]: 2022-12-01T04:27:52.801507Z 0 [System] [MY-
010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31-0ubuntu0.20.04.2) starting as
process 215978
Des 01 11:27:52 EMP10 mysqld[215978]: 2022-12-01T04:27:52.838390Z 1 [System] [MY-
013576] [InnoDB] InnoDB initialization has started.
Des 01 11:27:56 EMP10 mysqld[215978]: 2022-12-01T04:27:56.835576Z 1 [System] [MY-
013577] [InnoDB] InnoDB initialization has ended.
Des 01 11:27:57 EMP10 mysqld[215978]: mysqld: Table 'mysql.plugin' doesn't exist
Des 01 11:27:57 EMP10 mysqld[215978]: 2022-12-01T04:27:57.794572Z 0 [ERROR] [MY-
010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL
upgrade procedure.
Des 01 11:27:57 EMP10 mysqld[215978]: 2022-12-01T04:27:57.796461Z 0 [Warning] [MY-
010441] [Server] Failed to open optimizer cost constant tables
Des 01 11:27:57 EMP10 mysqld[215978]: 2022-12-01T04:27:57.797693Z 0 [Warning] [MY-
010441] [Server] Failed to open optimizer cost constant tables
Des 01 11:27:57 EMP10 mysqld[215978]: 2022-12-01T04:27:57.798994Z 0 [Warning] [MY-
010441] [Server] Failed to open optimizer cost constant tables
Des 01 11:27:57 EMP10 mysqld[215978]: 2022-12-01T04:27:57.800732Z 0 [Warning] [MY-
010441] [Server] Failed to open optimizer cost constant tables
Des 01 11:27:57 EMP10 mysqld[215978]: 2022-12-01T04:27:57.801853Z 0 [Warning] [MY-
010441] [Server] Failed to open optimizer cost constant tables
Des 01 11:27:57 EMP10 mysqld[215978]: 2022-12-01T04:27:57.803016Z 0 [Warning] [MY-
010441] [Server] Failed to open optimizer cost constant tables
Des 01 11:27:57 EMP10 mysqld[215978]: 2022-12-01T04:27:57.804443Z 0 [Warning] [MY-
010441] [Server] Failed to open optimizer cost constant tables
```
6.
```
emp10@EMP10:~$ sudo systemctl stop mysql
emp10@EMP10:~$ sudo mkdir /var/run/mysqld
emp10@EMP10:~$ sudo chown mysql:mysql /var/run/mysqld
emp10@EMP10:~$ mysqld --upgrade=FORCE
```
```
#log_warnings = 2
#log_slow_verbosity = query_plan
```
Ubuntu 20.04