In order to manage databases from the command line, it is usually connected using the database server administrator root access .
Note these accesses are different from the root password to access the VPS , the database server has its own user system.
For VPSs purchased with ServerManager, you can find the password in the /root/.mysqlpass file. In this case, you can make the connection using the command.
mysql -uroot -p`cat /root/.mysqlpass`
ServerManager needs to have the access password written in this file for correct database management, so if you change it, don’t forget to put the password in this file as well.
If you are not using ServerManager , you must set a password for the root user before accessing it. Initialize the password using:
mysqladmin password
After entering and repeating your password, you can connect:
mysql -uroot -pYOURPASSWORD