linux

Setting up MySQL Server on Ubuntu Server

1 min read

In the most recent versions of Ubuntu, after installing MySQL Server you cannot log in as the MySQL root user with a password unless you are the operating system’s root user.

To be able to log in as the MySQL root user from another Linux user, follow these steps on the command line:

bash
mysql_secure_installation

and follow the steps.

open MySQL

bash
mysql -u root

Change the authentication plugin of the root@localhost user

bash
mysql> update user set plugin="mysql_native_password" where host="localhost" and user="root";

then we can change the root user’s password

bash
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'desired_password';

Now we can log in even from another user on the server where MySQL is installed, or through an SSH tunnel from another computer (for example with MySQL Workbench).

#linux#mysql#ubuntu