Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

How to link MySQL from XAMPP (/opt/lampp/bin) to use mysql command from any directory in Ubuntu or Linux

Assumption:
I assume that you have already installed XAMPP in your Ubuntu OR Linux machine.
If not, then you may follow this link to do so: https://www.devopsschool.com/blog/installing-xampp-7-4-xxx-on-ubuntu/
and
https://www.devopsschool.com/blog/how-to-link-php-from-xampp-installation-to-use-php-command-from-user-or-any-other-directory-in-ubuntu-or-linux/

NOTE: I also assume that, you are going to use the MySQL database that comes with XAMPP for doing database interactions from the applications you are going to host on the XAMPP server of the Ubuntu or Linux machine

Why it is needed?
Ans: After installing XAMPP in Ubuntu or Linux machine, you might need to create databases or the database users to access them from the application you are planning to deploy on Ubuntu’s XAMPP.
In order to do any database related stuff you need to execute the commands start with mysql

Sample mysql commands:
mysql
which mysql
mysql -u root -p
show databases;
create user 'user_name'@'localhost' identified by 'password';
GRANT ALL PRIVILEGES ON * . * TO 'user_name'@'localhost';
FLUSH PRIVILEGES;
SHOW GRANTS user_name;
create database database_name;


What happens with MySQL after you install XAMPP in a brand new Ubuntu or Linux machine?

Ans: It throws Command not found error

Temporary Solution: Run command:
export PATH=$PATH:/opt/lampp/bin

Permanent Solution:
Step 1: Open .profile file in ubuntu user directory using command: sudo vi .profile
Step 2: Add the following line at the end of the .profile file in the vi editor
export PATH=$PATH:/opt/lampp/bin
Step 3: Save the file by press ESC followed by :wq commands
Step 4: Restart XAMPP server just to make sure it’s up and running:
sudo /opt/lampp/lampp restart
Step 5: Test if it’s working by running the below command:
mysql -u root -p

Refer the below screenshot to verify:

That’s it! I hope you enjoyed the article.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
Say goodbye to the hassles of bike ownership! MotoShare.in offers affordable rentals, whether you need a scooter for errands, a bike for a road trip, or a reliable ride to explore new cities.

Related Posts

How to Configure HTTP/HTTPS Proxy on Linux and Windows (CLI, GUI, Registry, and APT)

Set up proxy access correctly on Windows and Linux for command-line tools, package managers, and system-level use. This guide covers quick commands, persistent configuration, and common troubleshooting steps.

Read More

Linux pmap Command Guide: Inspect Process Memory Maps with Practical Examples

Learn how to use the Linux pmap command to inspect per-process memory mappings, compare output modes, and troubleshoot high memory usage quickly. This updated guide includes workflow steps, command examples, and interpretation tips.

Read More

iostat Command Guide for Linux: 20 Practical Examples for CPU and Disk I/O Troubleshooting

Learn how to use iostat to monitor CPU and storage performance on Linux systems. This revised guide covers installation, 20 practical commands, metric interpretation, and a troubleshooting workflow.

Read More

xargs in Linux: Practical Commands, Safe Patterns, and Pipeline Workflows

This guide explains how to use xargs effectively in Linux/Unix shells, from basic stdin handling to safe file operations and parallel execution. You’ll learn practical command patterns, portability caveats, and safer alternatives.

Read More

Linux mount and umount Commands: Practical Examples, /etc/fstab, and Safe Unmounting

Learn how to mount and unmount filesystems reliably on Linux, from one-off commands to persistent /etc/fstab entries. This guide covers common filesystem types, command comparisons, and safe troubleshooting steps.

Read More

How to Use gsh to Run Linux Commands Across Multiple Servers

gsh (Group Shell) lets you execute one command across many Linux hosts from a single terminal. This guide explains host grouping with /etc/ghosts, core options, and practical command patterns.

Read More