3

I only access to success with command:

mysql -u root -p

Another command like:

mysql

or

mysql -u root

have same error like:

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

I tried to set root user new password:

use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;

But only command mysql -u root -p working.

So, I can't install phpMyAdmin.

Show error like:

An error occurred while installing the database:                           
  │                                                                            
  │ ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using       
  │ password: NO)
hassan
  • 7,812
  • 2
  • 25
  • 36
Ave
  • 4,338
  • 4
  • 40
  • 67
  • what's the problem with the `-p` option ? it shouldn't cause any conflects with `phpmyadmin` , how are you trying to install `phpmyadmin` ? – hassan Mar 05 '17 at 07:57
  • .. with `-p` option. It requires the password to access `mysql console`. I login success. Problem issues with `mysql` or `mysql -u root`. I install `phpMyAdmin` with command: `sudo apt-get install phpmyadmin`. Normal, it working perfectly. But today, it has this issues. – Ave Mar 05 '17 at 08:02
  • excuse me , but your issue in installing phpmyadmin or in logging into mysql ? – hassan Mar 05 '17 at 08:08
  • I can't be logging into MySQL. When I tried to install phpMyAdmin have the error. I think this relate will provide more information to resolve my problem. – Ave Mar 05 '17 at 08:12
  • Be a superuser and check B:) – Rahul Mar 05 '17 at 08:15
  • when installing phpmyadmin, insert the root password as same as the mysql password and check , you can change it later . – hassan Mar 05 '17 at 08:18
  • What version of MySQL are you using? I've checked it twice but there is no `password` string in MySQL 5.7. In my version password is stored in 'authentication_string' field. Although it may differ with yours. Anyway there is a better way to change user password: `ALTER USER 'root'@'localhost' IDENTIFIED BY 'pass';` With this command MySQL makes hashing and reloading automatically and of course you don't need to pay attention on `user` table fields structure. Maybe you have failed with changing your `root` mysql password and now trying to install phpMyAdmin with the wrong pass? Can check it? – Alex Myznikov Mar 05 '17 at 08:25
  • I using version: `10.0.29-MariaDB-0ubuntu0.16.04.1 `. When config `mysql_secure_installation` I don't set password. After, I update it with command in `mysql console`. – Ave Mar 05 '17 at 08:31
  • 2
    Ok, so as I can see from https://mariadb.com/kb/en/mariadb/what-is-mariadb-100/ it is backported from MySQL 5.6. Here is grant tables description for it https://dev.mysql.com/doc/refman/5.6/en/grant-tables.html. In this version of MySQL there are both `password` and `authentication_string` fields in user table. But we can read here "The user table plugin, Password, and authentication_string columns store authentication plugin and credential information. It is up to the plugin whether it uses the Password and authentication_string column values. ". So I suggest you just try what I've proposed. – Alex Myznikov Mar 05 '17 at 08:43
  • Your comment provides information is very useful. Thanks – Ave Mar 05 '17 at 08:47
  • Did that help to solve your problem? – Alex Myznikov Mar 05 '17 at 08:48
  • Current I read your docs was the provider. I didn't resolve my problem. But I show your comment useful. – Ave Mar 05 '17 at 08:53
  • http://stackoverflow.com/questions/21944936/error-1045-28000-access-denied-for-user-rootlocalhost-using-password-y – jophab Mar 05 '17 at 09:26
  • Maybe it is not obvious so one more notice: `ALTER USER 'root'@'localhost' IDENTIFIED BY '';` will make your root pass blank so you will be able to use `mysql -u root` to login – Alex Myznikov Mar 05 '17 at 09:52

1 Answers1

0

-p option is "Using Password" option. By default, mysql doesn't ask for password unless -p option is provided. If you leave out this option it will try to log in without the password which is impossible.

So what you want to do is:

  1. Execute command mysql -u root -p
  2. Enter password
  3. ???
  4. Profit

In config files for installations (config.php usually has this) it is usually like:

DATABASE_NAME=["DB_NAME"]

DATABASE_USER=["root"] (Can be any username)

DATABASE_PASSWORD=["PASSWORD"] (Password of user above)

So installer or config will execute mysql -u root -p "PASSWORD" then when the script entered mysql console it will create database with name you provided.

More details on your issue are welcome, because I am bit confused what you are asking.

If you want to learn about mysql options, execute the command man mysql or visit this website for all options.