Accessing phpMyAdmin on Ubuntu through SQL

The cPanel page is divided into five sub panels, namely General settings, Appearance settings, Database server, Web server, and phpMyAdmin. To create a new user, connect with the MySQL server as a root user.

phpMyAdmin

is a very useful web-based database management tool to manage

MySQL or MariaDB

databases. It is a free tool that is written in PHP. Different types of database tasks can be done easily by using this tool.

phpMyAdmin

helps novice users to perform all types of basic database operations without having any knowledge of writing query. Some important features of this tool are mentioned below.

  • Perform various database operations such as creating, dropping, renaming, or altering databases, tables, columns, primary keys, unique keys, and indexes.
  • Manage the tables by adding, removing, or modifying records.
  • Administer the server by implementing different server settings.
  • Perform a variety of both straightforward and intricate queries.
  • Develop, remove and adjust stored procedures, triggers and views.
  • Transfer data between various formats by importing or exporting databases, tables, or individual data.

For web development, XAMPP or LAMP can be installed. When using XAMPP server on Ubuntu, phpMyAdmin doesn’t require a separate installation. It automatically comes with XAMPP server once it is installed. However, LAMP on Ubuntu requires downloading the phpMyAdmin package to install it. This guide will assist you in the process.

To commence the installation, it is essential to ensure that LAMP is functioning correctly. Verify the installation and functionality of Apache2, MySQL, and PHP by executing the given commands.

Verify the present condition of the Apache2 web server.


$


sudo

systemctl status apache2

Verify the connectivity of the database server, which is installed locally and is either MySQL or MariaDB.

[If no password is set for root]

$ sudo mysql

or

[If root user has password]

$ sudo mysql -u root -p

Verify the PHP version that has been installed.


$

php

-v

Launch a web browser and verify the operational status of the Apache server.

http://localhost

Once you have verified the completion of the tasks mentioned earlier, you may proceed with the installation of phpMyAdmin on your Ubuntu system.


Step-1: Install phpMyAdmin from Ubuntu repositories

Execute the update command prior to initiating the phpMyAdmin installation process.


$


sudo

apt update

To install phpMyAdmin from Ubuntu repositories, simply execute the command provided after updating. Grant permission to start the installation by pressing ‘y’ when prompted.


$


sudo

apt

install

phpmyadmin php-mbstring php-gettext

To select the Apache2 server, press the space bar and then click on “Ok” once the prompt appears.

To utilize dbconfig-common in configuring the database, simply choose “Yes” and hit the enter key.

Afterward, it’s necessary to establish a password for MySQL in order to establish a connection with the database server via phpMyAdmin. Enter the password, then select “Ok” and press the enter key.

Confirm your password by retyping it. Then, hit the “Ok” button and press enter.

To utilize phpMyAdmin Apache configuration file, execute the subsequent command to activate the PHP extension called mbstring.


$


sudo

phpenmod mbstring

To implement the installation, it is necessary to restart the Apache server.


$


sudo

systemctl restart apache2

After successful installation of phpMyAdmin, proceed to configure its other settings.


Step-2: Setup Authentication and Privileges

When installing phpMyAdmin for database tasks, a default username and password are provided. The username is ‘phpmyadmin’ and it is recommended to connect as the root user for all database operations. If no password is set for the root user when installing MySQL or MariaDB server, it is necessary to set one later. The root user can use either the ‘auth_socket’ or ‘mysql_native_password’ plugin to connect to the server. To enhance security, if the ‘auth_socket’ plugin is loaded for the root user, it is recommended to change the authentication method to ‘mysql_native_password’. Additionally, new user accounts can be created to access phpMyAdmin.


Configuration for root User:

Establish a connection to the database server and verify the present authentication technique being utilized by the user named “root”.

$ sudo mysql

> SELECT user,authentication_string,plugin,host FROM mysql.user;

Establish a password for the root user if it has not been previously established.

> SET PASSWORD ‘root’@’localhost’=PASSWORD(‘mynewpasword’);

If the current authentication method of the root user is ‘auth_socket’, use the alter command to modify it. The default authentication method is set to ‘mysql_native_password’, hence running the following command is unnecessary.

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

Execute the command to refresh the authentication and display the outcome of the alteration.

> FLUSH PRIVILEGES;

To verify the current authentication method of the user ‘root’, execute the same query once more.

> SELECT user,authentication_string,plugin,host FROM mysql.user;


Configuration for particular MySQL user:

To grant access to phpMyAdmin for a non-root user, follow these steps.

Connect to the MySQL server as the root user and establish a new user account by utilizing the “-p” option to connect to the server, as the password has been previously set for the root user.

$ mysql -u root -p

To create a new user named ‘linuxhint’, run the subsequent query.

> CREATE USER ‘linuxhint’@’localhost’ IDENTIFIED BY ‘secretpass’;

After creating a new user, it is necessary to grant them permissions to access the database server. To achieve this, execute the command below to set all the necessary permissions for the new user.

> GRANT ALL PRIVILEGES ON *.* TO ‘linuxhint’@’localhost’ WITH GRANT OPTION;

Now, exit from mysql prompt.


>


exit

Connect to phpMyadmin through a web browser.

To verify if phpMyAdmin is functioning correctly, simply open a browser and enter the URL.

http://localhost/phpmyadmin

After providing the credentials of either the root or newly created user, you can access the server and the subsequent page will be displayed.


Step-3: Using phpMyAdmin

The phpMyAdmin page consists of two panels. The left panel displays a comprehensive list of all the databases, tables, procedures, and views. To reveal the tables, procedures, and views of a specific database, you need to click the ‘+’ button corresponding to that database.

On the cPanel page, the right panel displays a range of database server information and tab options that allow users to perform specific database tasks. The page consists of five sub-panels, namely General settings, Appearance settings, Database server, Web server, and phpMyAdmin. Each of these panels serves a specific purpose and will be briefly explained here.

Overall Configuration:

Utilize this panel to display the index of MySQL charset and modify the collation of MySQL connection.

Settings for the way things look.

From this panel, you can modify various settings related to the appearance such as language, theme, and font size.


Database server:

This section displays diverse details relating to the database server, including but not limited to the server name, type, version, current user, and charset.


Web Server:

The information displayed on this panel pertains to the web server, the database client, and PHP.


phpMyAdmin:

This displays information about phpMyAdmin version and its associated details.


Tab options:

The menu tab situated at the top of the right panel facilitates several essential database operations, including creating or dropping databases or tables, executing SQL queries, exporting or importing databases, and creating or dropping triggers. Users can utilize the tab options to carry out these operations.

If you’re a web developer looking to simplify database tasks, phpMyAdmin is a must-have tool. To manage your database on a LAMP server through a web interface, simply follow this tutorial carefully and reap the benefits.

Frequently Asked Questions