Search code examples
mysqlserver

Error: Access denied for user 'root'@'localhost' MYSQL UBUNTU 20.04


am trying to deploy a website on a new server I install MYSQL using the command

sudo apt-get install mysql-server

After that I try to access the MYSQL command prompt using the command

sudo mysql -u root -p

it is giving me the error:

Access denied for user 'root'@'localhost' using password(NO).

Any idea on how to solve this? thanks!!


Solution

  • you have first to run

    sudo mysql_secure_installation
    

    after that you should have entered a password for root and the server is configured.

    You can also use after that

     sudo mysql
    

    to get access with administrator rights and change passwords or add new users