I installed mysql-server and it did not ask for a root password, and now i can't log into MySQL as root. Also, i noticed, that command "mysql_secure_installation" wants to secure a MariaDB database root account, not a MySQL one. I have been trying for days, but nobody could help me anywhere. What may the solution be? (Debian 9)
After initial installation you should run
mysql_secure_installation to set a password for root accounts. https://mariadb.com/kb/en/mariadb/mysql_secure_installation/
MariaDB Server is the default fork of MySQL in Debian 9.
In Debian 9 "Stretch" the
mysql-serverpackage depends on a new package called
default-mysql-server. This package in turn depends on
[..] when you install the
mysql-serverpackage on Stretch you will get MariaDB 10.1 instead of MySQL, like you would with previous versions of Debian. Note that
mysql-serveris just an empty transitional meta-package and users are encouraged to install MariaDB using the actual package
If you find some MySQL/MariaDB commands are running without any password prompt want to see what password it is using behind the scenes, Debian stores the generated passwords in
/etc/mysql# cat debian.cnf # Automatically generated for Debian scripts. DO NOT TOUCH! [client] host = localhost user = debian-sys-maint password = <random string> socket = /var/run/mysqld/mysqld.sock [mysql_upgrade] host = localhost user = debian-sys-maint password = <random string> socket = /var/run/mysqld/mysqld.sock basedir = /usr
I had the same problem which prevented me from being able to access mysql all the answers to use
mysql_secure_installation after running
sudo apt install mysql-server didn't work. Here's what worked
- Go to official mysql installation guide and follow line by line
- You need to download a .deb file from here that configures which version of mysql you want to install and other configurations
- After configurations are all done run
sudo apt-get update && sudo apt-get install mysql-serverThis time you'd be asked for a password.
Hope it helps. Cheers!