Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Are you quite certain that this is a fresh installation? –  Michael Hampton Aug 28 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 at 16:51
    
OK, what did you forget to mention? Obviously something else is going on here. –  Michael Hampton Aug 28 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 at 18:13

2 Answers 2

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.

share|improve this answer

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.

share|improve this answer
    
I have and it still denies access, but thanks. –  Jackie W Aug 28 at 16:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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