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 updatesudo apt install mysql-server
If 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.deb
Remove 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 mariadbsudo systemctl disable mariadb
Then remove it:
sudo apt remove mariadb-server mariadb-client
Then purge it. On Kali, purge removes a package along with its configuration files, which remove leaves behind:
sudo apt purge mariadb-server mariadb-client
Then run autoremove, which clears out packages that were installed as dependencies for something else and are no longer needed:
sudo apt autoremove
Install MySQL
With MariaDB gone, the install goes through:
sudo apt install mysql-server
Check 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 mysqlmysql --version
If it is not running, start it and have it come up on boot:
sudo systemctl start mysqlsudo systemctl enable mysql
A 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_installation
Then confirm you can actually get in:
sudo mysql -u root -p
If 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.







