{"id":9788,"date":"2020-01-31T03:53:06","date_gmt":"2020-01-31T03:53:06","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=9788"},"modified":"2020-05-27T08:20:58","modified_gmt":"2020-05-27T08:20:58","slug":"how-to-link-mysql-from-xampp-opt-lampp-bin-to-use-mysql-command-from-any-directory-in-ubuntu-or-linux","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-link-mysql-from-xampp-opt-lampp-bin-to-use-mysql-command-from-any-directory-in-ubuntu-or-linux\/","title":{"rendered":"How to link MySQL from XAMPP (\/opt\/lampp\/bin) to use mysql command from any directory in Ubuntu or Linux"},"content":{"rendered":"\n<p><strong>Assumption:<\/strong><br> I assume that you have already installed XAMPP in your Ubuntu OR Linux machine.<br>If not, then you may follow this link to do so:&nbsp;<a href=\"https:\/\/www.devopsschool.com\/blog\/installing-xampp-7-4-xxx-on-ubuntu\/\">https:\/\/www.devopsschool.com\/blog\/installing-xampp-7-4-xxx-on-ubuntu\/<\/a> <br>and<br> <a href=\"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\/\">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\/<\/a> <br><br><strong>NOTE:<\/strong> 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<br><br><strong>Why it is needed?<\/strong><br><strong>Ans: <\/strong>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&#8217;s XAMPP.<br>In order to do any database related stuff you need to execute the commands start with <code><strong>mysql<\/strong><\/code><br><br><strong>Sample mysql commands<\/strong>:<br><code>mysql<br>which mysql<br>mysql -u root -p<br>show databases;<br>create user 'user_name'@'localhost' identified by 'password';<br>GRANT ALL PRIVILEGES ON * . * TO 'user_name'@'localhost';<br>FLUSH PRIVILEGES;<br>SHOW GRANTS user_name;<br>create database database_name;<\/code><br><br><strong>What happens with MySQL after you install XAMPP in a brand new Ubuntu or Linux machine?<\/strong><\/p>\n\n\n\n<p> <strong>Ans:<\/strong>  It throws Command not found error<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"534\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-69.png\" alt=\"\" class=\"wp-image-9789\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-69.png 728w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-69-300x220.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p> <strong><span style=\"text-decoration: underline;\">Temporary Solution<\/span>:<\/strong> Run command: <br><code><strong>export PATH=$PATH:\/opt\/lampp\/bin<\/strong><\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"742\" height=\"46\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-70.png\" alt=\"\" class=\"wp-image-9790\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-70.png 742w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-70-300x19.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-70-740x46.png 740w\" sizes=\"auto, (max-width: 742px) 100vw, 742px\" \/><\/figure>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Permanent Solution:<\/span><\/strong><br><strong>Step 1:<\/strong> Open <strong>.profile<\/strong> file in <strong>ubuntu <\/strong>user directory using command: <code><strong>sudo vi .profile<\/strong><\/code><br> <strong>Step 2<\/strong>: Add the following line at the end of the <strong>.profile<\/strong> file in the vi editor<br> <code><strong>export PATH=$PATH:\/opt\/lampp\/bin <\/strong><\/code> <br><strong>Step 3:<\/strong> Save the file by press <code><strong>ESC <\/strong><\/code>followed by <strong><code>:wq<\/code><\/strong> commands<br><strong>Step 4:<\/strong> Restart XAMPP server just to make sure it&#8217;s up and running:<br><strong><code>sudo \/opt\/lampp\/lampp restart<\/code><\/strong><br><strong>Step 5:<\/strong> Test if it&#8217;s working by running the below command:<br><strong><code>mysql -u root -p <\/code><\/strong><br><\/p>\n\n\n\n<p><strong>Refer the below screenshot to verify:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"954\" height=\"352\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-71.png\" alt=\"\" class=\"wp-image-9792\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-71.png 954w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-71-300x111.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-71-768x283.png 768w\" sizes=\"auto, (max-width: 954px) 100vw, 954px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>That&#8217;s it! I hope you enjoyed the article.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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:&nbsp;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&#8230;<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[4957],"tags":[],"class_list":["post-9788","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=9788"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9788\/revisions"}],"predecessor-version":[{"id":9793,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9788\/revisions\/9793"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=9788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=9788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=9788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}