Reputation: 1751
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?
Upvotes: 13
Views: 14093
Reputation:
After installing Mysql on Ubuntu and similar one should run mysql_secure_installation command .
It clears some possible problems and one of the things is it asks for a new root password.
But previous answer from @Valuator will change the password.
Upvotes: 4
Reputation: 3617
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.
Upvotes: 33