Installing MySQL on Kali Linux can be a challenging task, and I struggled with it multiple times. I kept at it and spent considerable time finding a solution, and eventually got it working. This is the sequence that worked.
Try the normal way first
Update the system, then attempt the standard install:
sudo apt update
sudo apt install mysql-serverIf that fails, download the MySQL APT configuration package and continue below:
wget https://dev.mysql.com/get/mysql-apt-config_0.8.16-1_all.debRemove MariaDB first
The install often will not succeed on a fresh system, because Kali Linux comes with MariaDB as its default database management system and the two conflict. MariaDB has to go first.
The conflict is not arbitrary. MariaDB started as a fork of MySQL, so both packages want to own the same binary names, the same default data directory at /var/lib/mysql, and the same port 3306. apt will not let two packages claim the same files, which is why the install fails rather than warning you.
Stop and disable the MariaDB server:
sudo systemctl stop mariadb
sudo systemctl disable mariadbThen remove it:
sudo apt remove mariadb-server mariadb-clientThen purge it. On Kali, purge removes a package along with its configuration files, which remove leaves behind:
sudo apt purge mariadb-server mariadb-clientThen run autoremove, which clears out packages that were installed as dependencies for something else and are no longer needed:
sudo apt autoremoveInstall MySQL
With MariaDB gone, the install goes through:
sudo apt install mysql-serverCheck it actually worked
Installing the package is not the same as having a running server, and it is worth confirming which of the two you have before you go looking for problems elsewhere:
sudo systemctl status mysql
mysql --versionIf it is not running, start it and have it come up on boot:
sudo systemctl start mysql
sudo systemctl enable mysqlA fresh install ships with permissive defaults. The bundled hardening script walks through setting a root password and removing anonymous accounts, the test database, and remote root login:
sudo mysql_secure_installationThen confirm you can actually get in:
sudo mysql -u root -pIf something still fails after all this, the log is more useful than guessing. sudo journalctl -u mysql -n 50 will usually name the problem outright, and leftover MariaDB files in the data directory are the most common cause.





