I'm unable to start my MySQL server on Kubuntu 20.04. I've tried many times to install and to remove the installed packages. I've followed this thread: Can't get MYSQL8 to work on Ubuntu 20.04.
Following the suggestion of ExploitFate, I've got some improvements, but when I run:
sudo dpkg-reconfigure mysql-server-8.0I have the following output:
mysqld will log errors to /var/log/mysql/error.log
2021-05-14T20:21:24.150954Z 0 [ERROR] [MY-010946] [Server] Failed to start mysqld daemon. Check mysqld error log. Warning: Unable to start the server.If I try sudo systemctl status mysql.service the output is:
mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enabled) Active: failed (Result: exit-code) since Fri 2021-05-14 22:14:18 CEST; 1h 23min ago Main PID: 47596 (code=exited, status=1/FAILURE) Status: "Data Dictionary upgrade from MySQL 5.7 in progress"
may 14 22:14:16 hades systemd[1]: Starting MySQL Community Server... may 14 22:14:18 hades systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE may 14 22:14:18 hades systemd[1]: mysql.service: Failed with result 'exit-code'. may 14 22:14:18 hades systemd[1]: Stopped MySQL Community Server.Here is the error log file of mysql:
2021-05-14T21:16:55.848036Z 0 [Warning] [MY-011068] [Server] The syntax 'expire-logs-days' is deprecated and will be removed in a future release. Please use binlog_expire_logs_seconds instead.
2021-05-14T21:16:55.849055Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25-0ubuntu0.20.04.1) starting as process 48092
2021-05-14T21:16:55.860384Z 1 [System] [MY-011012] [Server]
Starting upgrade of data directory.
2021-05-14T21:16:55.860441Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-05-14T21:16:57.255989Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-05-14T21:16:57.259487Z 1 [ERROR] [MY-010781] [Server] Found ./mysql/index_stats.frm file in mysql schema. DD will create .ibd file with same name. Please rename table and start upgrade process again.
2021-05-14T21:16:57.259883Z 1 [ERROR] [MY-010336] [Server] Found .frm file with same name as one of the Dictionary Tables.
2021-05-14T21:16:57.260611Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2021-05-14T21:16:57.261061Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2021-05-14T21:16:57.262020Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-05-14T21:16:58.011540Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.25-0ubuntu0.20.04.1) (Ubuntu).
2021-05-14T21:16:58.016177Z 0 [ERROR] [MY-010065] [Server] Failed to shutdown components infrastructure.Apparently mysql is present, but I didn't finish the configuration of it.
I don't have more ideas and I think I'm in a deadlock. Any ideas to help me?
13 Answers
It is the password.
I had the same issue and solved it yesterday, as well on a Kubuntu 20.04 and MySQL-Server 8.0.
Since you have already tried a few things, you have some errors in the system, these must be fixed first.
Now you have to uninstall the MySQL server completely.
su root
systemctl stop mysql.service
systemctl disable mysql.service
systemctl stop avahi-daemon.service
systemctl stop avahi-daemon.socket
apt autoclean
apt cleanIf installed, also remove php and phpmyadmin. If not skip this step.
apt remove --purge phpmyadmin
apt remove --purge php-*Watch the uninstall log, look for warnings and error messages.
dpkg: warning: while removing php7.4-cli, directory '/etc/php/7.4' not empty so not removed
rm -rf /etc/php/7.4Continue
apt remove --purge mysql*
dpkg --configure -a
apt autoremove
rm -rf /etc/mysql /var/opt/mssql /usr/bin/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gzThis command will delete the MySQL user and all associated files, therefore the disk will be completely scanned for MySQL user data and depending on the speed, size and occupancy this may take longer. Unmount all other disks.
deluser --remove-all-files --force mysqlAt this point you will get an warning message.
Removing files ...
Removing user mysql ...
Warning: group mysql has no more members.
Done.
Check if the group mysql is removed.
cat /etc/passwd | grep mysql
cat /etc/group | grep mysqlShould be without resultet, empty.
Now reboot the system
rebootNext reinstall the MySql-Server
su root
apt update --fix-missing && apt --fix-broken install && apt full-upgrade && apt autoremove
apt install php
apt install php-mysql
apt install mysql-server
mysql_secure_installationUse a password with at least 8 characters, of which at least one must be an uppercase letter, one a lowercase letter, one a number and one a special character.
Not all special characters are allowed, but there is no error message if you enter a wrong character and that's the problem.
Use these: ( )
Example password: H4CkM31Fy()Uc4n
password validation police
10I provide you a screenshot. You can see that when I execute mysql_secure_installation I get an error, since I cannot connect to MySQL.
If I execute mysql -u root -p and I type the root password the shell answer me:
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
After I rebooted the computer I cannot login to mysql, but I have this status:
javier@hades:~$ sudo systemctl status mysql.service ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enable> Active: inactive (dead)
Then I try:
javier@hades:~$ 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 -xe" for details. javier@hades:~$ sudo systemctl status mysql.service ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enable> Active: failed (Result: exit-code) since Sat 2021-05-15 04:33:40 CEST; 16s ago Process: 2637 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, s>
may 15 04:33:40 hades systemd1: mysql.service: Scheduled restart job, restart counter> may 15 04:33:40 hades systemd1: Stopped MySQL Community Server. may 15 04:33:40 hades systemd1: mysql.service: Start request repeated too quickly. may 15 04:33:40 hades systemd1: mysql.service: Failed with result 'exit-code'. may 15 04:33:40 hades systemd1: Failed to start MySQL Community Server.
I rebooted again my computer and I check if KWallet is working. I think it is working as you can see.
javier@hades:~$ systemctl status | grep kwalletd5 │ ├─1808 /usr/bin/kwalletd5 --pam-login 7 3 │ └─2554 grep --color=auto kwalletd5I've also added the first lines of my status:
hades State: running Jobs: 0 queued Failed: 0 units Since: Sat 2021-05-15 12:42:38 CEST; 1h 5min ago CGroup: / ├─413 bpfilter_umh ├─user.slice │ └─user-1000.slice │ ├─ │ │ ├─pulseaudio.service │ │ │ └─1803 /usr/bin/pulseaudio --daemonize=no --log-target=journal │ │ ├─init.scope │ │ │ ├─1789 /lib/systemd/systemd --user │ │ │ └─1790 (sd-pam) │ │ ├─obex.service │ │ │ └─2113 /usr/lib/bluetooth/obexd │ │ └─dbus.service │ │ ├─1805 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfil> │ │ ├─1903 /usr/libexec/dconf-service │ │ ├─1926 /usr/bin/kglobalaccel5 │ │ ├─1935 /usr/lib/x86_64-linux-gnu/libexec/kactivitymanagerd │ │ ├─2039 /usr/lib/x86_64-linux-gnu/libexec/kf5/kscreen_backend_launcher │ │ └─2166 /usr/lib/x86_64-linux-gnu/libexec/baloorunner │ └─session-6.scope │ ├─1776 /usr/lib/x86_64-linux-gnu/sddm/sddm-helper --socket /tmp/sddm-auth26e7f> │ ├─1808 /usr/bin/kwalletd5 --pam-login 7 3 │ ├─1809 /usr/bin/startplasma-x11 │ ├─1855 /usr/bin/ssh-agent /usr/bin/im-launch /usr/bin/startplasma-x11 │ ├─1876 /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit --kded +kcminit_sta> │ ├─1877 kdeinit5: Running... │ ├─1883 /usr/lib/x86_64-linux-gnu/libexec/kf5/klauncher --fd=9 │ ├─1886 kded5I've uninstalled KWalletManager and installed again. I provide you the first lines of my systemctl status.
javier@hades:~$ systemctl status
● hades State: degraded Jobs: 0 queued Failed: 1 units Since: Sat 2021-05-15 12:42:38 CEST; 1h 34min ago CGroup: / ├─413 bpfilter_umh ├─user.slice │ └─user-1000.slice │ ├─ │ │ ├─pulseaudio.service │ │ │ └─1803 /usr/bin/pulseaudio --daemonize=no --log-target=journal │ │ ├─init.scope │ │ │ ├─1789 /lib/systemd/systemd --user │ │ │ └─1790 (sd-pam) │ │ ├─obex.service │ │ │ └─2113 /usr/lib/bluetooth/obexd │ │ └─dbus.service │ │ ├─1805 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfil> │ │ ├─1903 /usr/libexec/dconf-service │ │ ├─1926 /usr/bin/kglobalaccel5 │ │ ├─1935 /usr/lib/x86_64-linux-gnu/libexec/kactivitymanagerd │ │ ├─2039 /usr/lib/x86_64-linux-gnu/libexec/kf5/kscreen_backend_launcher │ │ └─2166 /usr/lib/x86_64-linux-gnu/libexec/baloorunner │ └─session-6.scope │ ├─1776 /usr/lib/x86_64-linux-gnu/sddm/sddm-helper --socket /tmp/sddm-auth26e7f> │ ├─1808 /usr/bin/kwalletd5 --pam-login 7 3 │ ├─1809 /usr/bin/startplasma-x11 │ ├─1855 /usr/bin/ssh-agent /usr/bin/im-launch /usr/bin/startplasma-x11 │ ├─1876 /usr/lib/x86_64-linux-gnu/libexec/kf5/start_kdeinit --kded +kcminit_sta> │ ├─1877 kdeinit5: Running... │ ├─1883 /usr/lib/x86_64-linux-gnu/libexec/kf5/klauncher --fd=9 │ ├─1886 kded5 │ ├─1904 /usr/bin/kaccess │ ├─1909 /usr/bin/xsettingsd │ ├─1918 /usr/bin/plasma_session │ ├─1933 /usr/bin/ksmserver │ ├─1943 /usr/bin/kwin_x11 -session 10100109dae2000148598483700000013020002_1621> │ ├─1945 /usr/bin/baloo_file │ ├─1947 /usr/bin/plasmashell │ ├─1949 /usr/lib/x86_64-linux-gnu/libexec/polkit-kde-authentication-agent-1 │ ├─1958 /usr/bin/xembedsniproxy │ ├─1961 /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd │ ├─1966 /usr/bin/gmenudbusmenuproxy │ ├─1985 /usr/lib/x86_64-linux-gnu/libexec/DiscoverNotifier │ ├─2037 /usr/libexec/at-spi-bus-launcher --launch-immediately │ ├─2045 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessib> │ ├─2053 /usr/libexec/geoclue-2.0/demos/agent │ ├─2062 /usr/lib/x86_64-linux-gnu/libexec/org_kde_powerdevil │ ├─2133 /usr/bin/ksysguardd │ ├─2508 file.so [kdeinit5] file local:/run/user/1000/klauncherOupbUr.1.slave-so> │ ├─3167 /usr/bin/dolphin │ ├─3181 file.so [kdeinit5] file local:/run/user/1000/klauncherOupbUr.1.slave-so> │ ├─3277 /usr/bin/kate -b /home/javier/Programas/Amarok/amarok-2.9.71/amarok-2.9> │ ├─3293 /usr/lib/firefox/firefox │ ├─3373 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLe> │ ├─3429 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLe> │ ├─3463 /usr/lib/firefox/firefox -contentproc -childID 3 -isForBrowser -prefsLe> │ ├─3513 /usr/bin/plasma-browser-integration-host /usr/lib/mozilla/native-messag> │ ├─3567 /usr/lib/firefox/firefox -contentproc -parentBuildID 20210504152106 -pr> │ ├─3720 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLe> │ ├─3823 /usr/bin/konsole │ ├─3830 /bin/bash │ ├─3901 /usr/lib/firefox/firefox -contentproc -childID 8 -isForBrowser -prefsLe> │ ├─4549 systemctl status │ └─4550 pager ├─init.scope │ └─1 /sbin/init splash 8 Reset the root password via CLI in MySQL-Server
Fix for error messages related to the root password.
Open a CLI and log in as root.
su rootIt should now be possible to log via CLI in to MySQL without a password.
mysql -u rootEnter this syntax
SELECT user,host,plugin FROM mysql.user WHERE user='root';+------+-----------+-----------------------+ | User | Host | plugin | +------+-----------+-----------------------+ | root | % | auth_socket | +------+-----------+-----------------------+
The result should look like this.
If the root has wildcard % privileges, change them to localhost. If root is localhost, skip this step.
UPDATE mysql.user SET Host='localhost' WHERE User='root' AND Host='%';Change the plugin for the root to caching_sha2_password
UPDATE mysql.user SET Plugin='caching_sha2_password' WHERE User='root' AND Host='localhost';Now flush the settings.
FLUSH PRIVILEGES;Should look like this in the end.
SELECT user,host,plugin FROM mysql.user WHERE user='root';+------+-----------+-----------------------+ | User | Host | plugin | +------+-----------+-----------------------+ | root | localhost | caching_sha2_password | +------+-----------+-----------------------+
Finally restart the MySQL server.
systemctl stop mysql.service
systemctl disable mysql.service
systemctl enable mysql.service
systemctl start mysql.serviceSometimes it doesn't work and you have to restart the computer.
Check if the KWalletManager is working properly.
systemctl statusState: degraded Jobs: 0 queued Failed: 3 units Since: Fri 2021-05-14 16:48:54 CEST; 19h ago CGroup: / ├─user.slice │ └─user-1000.slice │ ├─ … │ │ ├─pulseaudio.service │ │ │ └─994 /usr/bin/pulseaudio --daemonize=no --log-target=journal │ │ ├─init.scope │ │ │ ├─988 /lib/systemd/systemd --user │ │ │ └─989 (sd-pam) │ │ ├─obex.service │ │ │ └─1337 /usr/lib/bluetooth/obexd │ │ └─dbus.service │ │ ├─1011 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --sys> │ │ ├─1109 /usr/bin/kglobalaccel5 │ │ ├─1114 /usr/libexec/dconf-service │ │ ├─1163 /usr/lib/x86_64-linux-gnu/libexec/kactivitymanagerd │ │ ├─1210 /usr/lib/x86_64-linux-gnu/libexec/kf5/kscreen_backend_launcher │ │ ├─1431 /usr/bin/krunner │ │ ├─1452 /usr/lib/x86_64-linux-gnu/libexec/baloorunner │ │ └─1560 /usr/bin/kwalletd5
systemctl status | grep kwalletd57│ │ └─1560 /usr/bin/kwalletd5 │ └─24924 grep --color=auto kwalletd5