Setting up mariadb or mySQL on Ubuntu/Linuxmint

Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
  • User AvatarInder Singh Thakur
  • 28 Jan, 2022
  • 0 Comments
  • 1 Min Read

Setting up mariadb or mySQL on Ubuntu/Linuxmint

This is quick blog to setup a Mariadb or Mysql in newly installed Ubuntu or any of the ubuntu based derivative such as LinuxMint (which is one of the most popular OS)

Earlier when you use to install mySQL, user was required to enter mySQL Password for root user. but in recent version there is no such prompt, and you can login to mySQL using sudo command. The problem is when you configure phpmyadmin it asks for username and password and since you have not setup the username and password you get struck. I will not get into the details of why this is happening just telling you the quick solution.

First login using sudo mysql

$ sudo mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.0.27-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.

mysql>

Now enter Following Command to select mysql database and then change your login method 

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> UPDATE user SET plugin=’mysql_native_password’ WHERE User=’root’;
Query OK, 1 row affected (0.17 sec)
Rows matched: 1  Changed: 1  Warnings: 0

you have successfully changed the login method by setting the plugin t mysql_native_password. Now you need to set up the password for root user. Dont forget to change the password otherwise you may not be able to login. Issue following command to do so.

mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘
password’;

you need to provide the password that you want to use in single quote.


Query OK, 0 rows affected (0.15 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.05 sec

and you can quit now 

you have successfully changed the login method and can configure phpmyadmin or login through console using standard command i.e.

$ sudo mysql -u root -p

and you will be prompted for pasword to proceed to login.

Leave a Reply

Your email address will not be published. Required fields are marked *

X