4

I am on linux and I have never installed a database management system but when I type in the terminal mysql --version I get mysql Ver 15.1 Distrib 10.1.26-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2.

I can connect to the database without a password when I type mysql without any password.

Meanwhile, I installed Adminer and I would like to use it alternatively phpmyadmin to manage my database but I can not connect myself I receive the following error in my browser Access denied for user 'root' @ 'localhost'.

I try all the methods found on google google to create a root password but I can not.

I tried the solutions proposed here:

And many oder link.

How can I set a root password for mysql to use it in Adminer

Carlos Cavero
  • 3,011
  • 5
  • 21
  • 41
  • Can you try to connect from the console using `mysql -u root -p` and then enter the configured password? If that works the configuration for Adminer is wrong. If that doesn't work, you need to show us the exact commands you've tried – JensV May 03 '19 at 13:43
  • I have already tried and I arrive so connected to me no matter what password I enter –  May 03 '19 at 13:48
  • Can you try this not using the root user on the machine? As that is probably what is bypassing the authentication – JensV May 03 '19 at 13:50
  • and which user should I use? –  May 03 '19 at 13:52
  • Any user which isn't root – JensV May 03 '19 at 13:57

2 Answers2

4

If you have never set a root password for MySQL, the server does not require a password at all for connecting as root. To set up a root password for the first time, use the mysqladmin command at the shell prompt as follows:

mysqladmin -u root password newpass
1

I followed this Link. The initial Mysql Setup didnt work, so I did a password reset. Mysql Version 5.7.38:

Warning: During this operation your anyone can access your MYSQL Server without password!

$> sudo nano /etc/mysql/my.cnf
[mysqld]          # add if not present
skip-grant-tables # add line
$> sudo mysql restart && mysql #should login with user root without password
mysql> USE mysql;
mysql> UPDATE user SET authentication_string=PASSWORD("YourNewPassword") WHERE user='root';

The following SQL was important:

mysql> UPDATE user set plugin="mysql_native_password" where user='root';
mysql> FLUSH privileges;
mysql> QUIT;
sudo nano /etc/mysql/my.cnf
  skip-grant-tables #remove line
Zykrates
  • 61
  • 4