How can I find out Mysql root password?

Thommen

New member
Joined
Feb 22, 2021
Messages
14
Following the example of the website → https://help.directadmin.com/item.php?id=45

I have an error ↓
sudo systemctl stop mysqld
admin@server313851:~$ sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables" admin@server313851:~$ sudo systemctl start mysqld admin@server313851:~$ mysql mysql -e "UPDATE mysql.user SET authentication_string=null WHERE user='root'; FLUSH PRIVILEGES;" ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password: NO)
I have
mysqld --version mysqld Ver 5.7.31 for linux-glibc2.12 on x86_64 (MySQL Community Server (GPL))
 
da_admin pass = /usr/loca/directadmin/conf/my.cnf

mysql root pass = /usr/local/directadmin/scripts/setup.txt
which by the way also contains the da_admin pass.

Normally you don't need the mysql root pass and use da_admin.
 
da_admin pass = /usr/loca/directadmin/conf/my.cnf

mysql root pass = /usr/local/directadmin/scripts/setup.txt
which by the way also contains the da_admin pass.

Normally you don't need the mysql root pass and use da_admin.

This is correct but not many people know (I've never seen this post on forum) that during Directadmin installation, it actually created a mysql root password (not the blank one but it doesn't use it). If you look at the installation log file, you will see the following line that said:

# /var/log/directadmin/install.log

Code:
####Setting password: SET PASSWORD FOR 'root'@'localhost' = PASSWORD('*******');

You can test login phpmyadmin with the username root and the above password. It works. That means, you should secure this password or secure your mysql installation with mysql_secure_installation command to not allow root login. Always block remote root login in mysql.

I think the password was generated from mysql installer not Directadmin. Directadmin doesn't set the root password for mysql
 
Last edited:
you will see the following line that said:
Isn't that the same mysql root pass which is also visible in the setup.txt I mentioned?

Also.... is this still happening and if yes, in which distro?
Because I installed a new DA server in Februari and there is no such line to be found in my install.log file.
Neither in my install.log of the server installed september last year. Both Centos 7 and neither in the Centos 8 server also from around that time.

The mysql installer does not generate a root password as far as I know.

Always block remote root login in mysql.
That is always good practice for security.

P.s. the mysql root pass in setup.txt is posted a couple of times on the forums. You might have never seen it, but it's there. ;)
 
Isn't that the same mysql root pass which is also visible in the setup.txt I mentioned?

That is different. In setup.txt the username is `da_admin` (that was created by Directadmin as root user) but the one that I mentioned is root (with username root). During DA installation, it creates a short root password for me (it's different from da_admin mysql password and yes 'da_admin as root password' has been documented many times in this forum). Now I remember that I got this installation log directly from Putty terminal (eg. in Putty it has an option to copy all output to clipboard called 'Copy All to Clipboard'). I think it was not log in install.log maybe the output was not a standard output (only appear in terminal). I still have this note about this last few months on my custom installation script below and it appears on Debian):

1618322730104.png

The full output specific to sql password that I got was:

Code:
##### MySQL root password seems to be unset, setting using MySQL queries...
####Setting password: SET PASSWORD FOR 'root'@'localhost' = PASSWORD('*******');

After I found this log file, I straight away use this in phpMyAdmin and it works (I was logged as root username not da_admin). The password in the log is visible not that asterik symbol. The asterik symbol I just masked it.


But no worries ... I'm going to test this with fresh installation again and let you know if this still happen.
 
Last edited:
That is different. In setup.txt the username is `da_admin`
Did you even thoroughly looked at the setup.txt? Because I'm talking the whole time about root, not about da_admin which is -also- in there,

Have another look. ;)

The output during installation should be the same as in setup.txt for mysql root.
 
Did you even thoroughly looked at the setup.txt? Because I'm talking the whole time about root, not about da_admin which is -also- in there,

Have another look. ;)

The output during installation should be the same as in setup.txt for mysql root.
I will check this again as I don't have any DA server running right now (reconstructing physical server).
 
Ok, I just installed DA now with fresh installation.

I was wrong about what I said above that setup.txt contains only da_admin sql password. sorry about that.

I remember I read from one post (I think I read it wrong) that Directadmin will never create or store mysql root password and starting from that moment I put a note and I never believe that this setup.txt contains mysql root password (as root username, I thought the password belongs to da_admin and it has the same location as in /usr/local/directadmin/conf/mysql.conf). Until I found that the root password is actually came from the terminal log I posted previously and I thought that the hidden sql root password is only came from that terminal output. Normally after DA installation (before I found the sql password log) I would reset root password manually through terminal (stopping mysqld)

Also if you look at setup.txt here, the way how the password is arranged is a bit confused to me as it doesn't mention that the mysql password belongs to root username (it's written as mysql=3Fqvk...., should put like mysql_root=3Fqvk... so that will become more obvious) and below it mysqluser=da_admin which makes me more confused that it is not mysql root password but only belongs to da_admin. Why would you put mysql 'da_admin' user here without putting its own password together in setup.txt? Confused right? or maybe change this variable mysqluser=da_admin to mysqluser=root and it becomes more obvious this mysql password in setup.txt belongs to root user.

1618850489517.png

Another thing, I might had overlooked at this high rank post for example when I try to search `where is mysql root password in Directadmin` from Google it appears first and the post did not mention anything about mysql root user. This is another reason why I didn't believe root password does exist in setup.txt and it's hidden somewhere and the way to recover it is by the last post (reset through terminal) 🤭


About the log file, yes it still there (not in setup log file but from terminal) and I just realized it has the same password as in setup.txt.

1618851060380.png

For many years, now I understand that setup.txt contains this mysql root password where mysql.conf contains only da_admin sql password.

Thanks a lot @Richard G
 
Last edited:
and below it mysqluser=da_admin which makes me more confused that it is not mysql root password but only belongs to da_admin.
I totally agree that this works very confusing. When I was looking at it a couple of years ago. I encountered the setup.txt and remembered the da_admin pass looked different in the my.cnf in the config directory. So I went searching and then found out this was the root pass.

You're welcome.
 
Back
Top