Mysql maintains it's own user and password information which are different from the main operating system accounts. The root@localhost and root@yourhost.tld accounts are the default administrator accounts for an installation on CentOS.
If you have recently installed this mysql server and you have not set a password then you should be able to access it with a blank password
mysql -u root -p
Enter password: (press enter)
or
mysql -h yourhostname.tld -u root -p
Enter password: (press enter)
If you can do this then you should secure your system by setting a password
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h yourhostname.tld password 'new-password'
or run
/usr/bin/mysql_secure_installation
Which will give you various options for securing your system. Pay particular attention to the
Disallow root login remotely? [Y/n]
Question
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
But you appear from your question to want to allow this (although you probably don't really).
If someone else has set this system up for you and they have set a password you should ask them for it.
If a password has been set and you cannot obtain it then you can reset the password with the following procedure providing you have root access to the OS.
service mysqld stop
mysqld_safe --skip-grant-tables &
mysql --user=root mysql
update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
exit;
Now stop mysql
pkill mysql
and restart the service
service mysql start
You should be able log on with your know password.
Best Answer
After initial installation you should run
mysql_secure_installation
to set a password for root accounts. https://mariadb.com/kb/en/mariadb/mysql_secure_installation/MariaDB Server is the default fork of MySQL in Debian 9.
https://www.debian.org/releases/stretch/amd64/release-notes/ch-whats-new.en.html#mariadb-replaces-mysql
https://mariadb.com/resources/blog/mariadb-server-default-debian-9
source: https://mariadb.com/kb/en/library/moving-from-mysql-to-mariadb-in-debian-9/