Mysql – MariaDB RHEL Fresh Install Root Login Issue

mariadbMySQLredhatsystemctl

I just installed MariaDB on a RHEL system and this is my first time using MariaDB. I can start/stop the service only using the following commands:

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service 

sudo systemctl stop mariadb.service

Now, when I try to use the following:

mysql --user=root

I'm given the following error:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Being a fresh install I would expect the password to be blank and I have uninstalled and reinstalled hoping that might resolve the issue but clearly it didn't.

I have read about using –skip-grant-tables to reset the password for root but I have been unable to start the service with this option in place given that I have to use systemctl. I'm not sure if perhaps I'm putting the option in the wrong location in the command, but I have tried a number of methods to no avail.

No other commands (from /etc/init.d) work at all to get this service running.

If anyone can assist in helping me get the –skip-grant-tables working or to figure out how to somehow reset the root password for mariadb, or somehow set up another user with all privileges, I would greatly appreciate it. Thanks.

Best Answer

Try running mysql_secure_installation - improve MySQL installation security, as Michael mention, it almost sounds like you already have mysql database with something other than fresh install.

You can also try stop mariadb.service delete mysql database and then try to give it another try with mysql_install_db - initialize MySQL data directory.