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.

  • Are you quite certain that this is a fresh installation? – Michael Hampton Aug 28 '14 at 16:20
  • Yes, this is a fresh install. Brand new server. I installed once and ran into this issue and tried removing and installing once again and still the same issue presents itself. – Jackie W Aug 28 '14 at 16:51
  • OK, what did you forget to mention? Obviously something else is going on here. – Michael Hampton Aug 28 '14 at 16:57
  • What I forgot to mention is that I don't actually have access to the root password itself (against IT practices to provide this to non-IT individuals, even though they were giving me this server to do with as I pleased). The system was forcing the entry of the actual root password and would not work with a blank password. Once the actual root pass was entered, it worked fine. A user was created for myself to use and now it's working. Thanks all. – Jackie W Aug 28 '14 at 18:13

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.


Try running the client as root.. It's likely that the default is unix socket auth for root, which checks if the UID of the process is the required UID for the user (in this case, 0) and allows/denies based on that.


Have you tried: mysql --user=root -p and then when asked for the password, just pressing enter?

Sorry it this is obvious and you have, thought it worth a mention just in case.

  • I have and it still denies access, but thanks. – Jackie W Aug 28 '14 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.