[Ubuntu Server] How to change the mysql password using command line
by Riley MacDonald, November 5, 2017
While installing WordPress on Ubuntu Server I wanted to change the root password for mysql
. Since I’m using a headless server I needed to do it manually using the command line. Here’s how I updated the password:
Log into mysql:
$ mysql -u root -p |
Select the database using use mysql;
, set the new password and invoke FLUSH PRIVILEGES;
.
mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> SET PASSWORD FOR 'username'@'hostname' = PASSWORD('new-password'); Query OK, 0 rows affected, 1 warning (0.09 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.18 sec) mysql> exit Bye |
User Comments:
[…] installing/configuring the server I used a default password “root” for mysql. This post shows how to change the mysql password using the command […]