Error logging in

I have installed MariaDB on Ubuntu 16.04. But when trying for the first time is says:

~$ mysql
ERROR 1045 (28000): Acces denied for user 'username'@ 'localhost' (using password: NO)

And when I try mysql_secure_installation to set a root password is says:

~$ mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Enter current password for root (enter for none): 

Giving Enter doesn't work. I read something about "UNIX_SOCKET plugin is installed by default in new installs of Ubuntu 15.10" but I do not understand how I can log in with this. I hope getting a answer soon!

Answer Answered by kanika satija in this comment.

It seems that you have forgotten root password which was set during installation of MariaDB

Solution:- reset root password

Follow below steps to reset root password:- 1) Stop mariadb services service mysql stop

2) Run mysqld safe version by below command sudo mysqld_safe --skip-grant-tables &

3) Run mysql client with below commnad on new terminal mysql -u root

4) Set password in user table of mysql database use mysql; update user SET PASSWORD=PASSWORD("<new_password>") WHERE USER='root'; flush privileges; exit

5) Login with new password, set in above command mysql -u root -p Enter password: <new_password>

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.