Slide 1
Excellent Education Program
Innovative Methods of Teaching

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cum sociis natoque penatibus et magnis dis parturient.

Slide 2
Learning Through Play
Devoted to the Early Education

Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.

Slide 2
Learning Through Play
Devoted to the Early Education

Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.

Slide 2
Learning Through Play
Devoted to the Early Education

Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.

Slide 2
Learning Through Play
Devoted to the Early Education

Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.

Slide 3
Learning Through Play
Find a Class for your Children

Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis.

previous arrow
next arrow

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

Spread the Knowledge

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.

Chetan