Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL 5.7.20 unable to set root password

Tags:

mysql

I installed MySQL Server 5.7.20 on ubuntu 14.04 and i can log in to server using:

mysql -u root -p

password is blank...how can i set mysql root password in terminal before install mysql server?

I installed it using silent install and try to run from terminal this mysql query:

SET PASSWORD FOR 'root'@'localhost' = 'mypasswordhere';

But i im getting this:

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> SHOW warnings;
+-------+------+------------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                    |
+-------+------+------------------------------------------------------------------------------------------------------------+
| Note  | 1699 | SET PASSWORD has no significance for user 'root'@'localhost' as authentication plugin does not support it. |
+-------+------+------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

So what i im doing wrong? I just want to change from blank password for user root to mypasswordhere password...how it needs to be done?

like image 582
John Avatar asked Nov 03 '17 15:11

John


People also ask

How set MySQL root password?

Use the following procedure to set a root password. To change the root password, type the following at the MySQL/MariaDB command prompt: ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyN3wP4ssw0rd'; flush privileges; exit; Store the new password in a secure location.

How do I enable root access in MySQL?

To allow remote connections to the root account in MySQL, you should execute the mysql_secure_installation command. Normally you run this command when first setting up MySQL, but it can be run again at any point if you need to reset the root account password or allow remote connections to the account.

What is the default password for MySQL root?

The default user for MySQL is root and by default it has no password.

How do I find my current MySQL root password?

user SET Password=PASSWORD('new password') WHERE User='root'; FLUSH PRIVILEGES; mysqladmin -u root -p shutdown Note: Once you shutdown mysqladmin, you would be seeing the safe mode exits in Terminal 1. sudo service mysql start That's it and it works like a charm with the new password!

Does MySQL require a root password to install?

I have a new droplet with Ubuntu 18.04 and am installing MySql using It seems to install fine but does not ask for a root password on install, I am pretty sure this is as it is expected to work. With this from the cli I can log into it with just using ‘mysql’, while that is handy it is not very secure.

Why did I get an error while setting the MySQL password?

An error occurred while setting the password for the MySQL administrative user. This may have happened because the account already has a password, or because of a communication problem with the MySQL server. You should check the account's password after the package installation.

What happens if I don’t give root user a password?

Show activity on this post. If you install 5.7 and don’t provide a password to the root user, it will use the auth_socket plugin. That plugin doesn’t care and doesn’t need a password. It just checks if the user is connecting using a UNIX socket and then compares the username.

How to uninstall MySQL server completely?

I too faced the same issue but the following worked for me: Go to Control Panel >> Programs >> Programs and Features, select MySQL Server and click Uninstall. Also uninstall the MySQL workbench, MySQL Installer Community, MySQL Router. Then delete the files:


1 Answers

Try

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mypasswordhere';

From https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/

If you install 5.7 and don’t provide a password to the root user, it will use the auth_socket plugin. That plugin doesn’t care and doesn’t need a password. It just checks if the user is connecting using a UNIX socket and then compares the username. If we want to configure a password, we need to change the plugin and set the password at the same time, in the same command.

like image 171
Valuator Avatar answered Oct 06 '22 23:10

Valuator