{"id":1510,"date":"2016-03-22T16:02:52","date_gmt":"2016-03-22T23:02:52","guid":{"rendered":"http:\/\/internetofhomethings.com\/homethings\/?p=1510"},"modified":"2016-04-29T15:04:15","modified_gmt":"2016-04-29T22:04:15","slug":"usb-lamp-web-server-part-3-adding-mysql-server","status":"publish","type":"post","link":"https:\/\/internetofhomethings.com\/homethings\/?p=1510","title":{"rendered":"USB LAMP Web Server Part 3 &#8211; Adding mySQL Server"},"content":{"rendered":"<p><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/phpmysql2.jpg\" rel=\"attachment wp-att-1530\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1530\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/phpmysql2.jpg\" alt=\"phpmysql2\" width=\"408\" height=\"408\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/phpmysql2.jpg 204w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/phpmysql2-150x150.jpg 150w\" sizes=\"auto, (max-width: 408px) 100vw, 408px\" \/><\/a><\/p>\n<p>A\u00a0web server is certainly not complete without a database server.\u00a0Currently, the one-source server of choice is mySQL. At first, adding this database server to my Linux setup\u00a0update appeared to be simple and straight-forward. Just add another package to the Puppy Linux installation and restart &#8211; instant mySQL server capability. But then I soon found that it was not going to be that simple.<\/p>\n<p>Still, after persistent effort to overcome several patience-trying obstacles, the installation was finally complete. Presented here are the successful steps to adding mySQL Server, without having do deal with the problems. And for those who do not want to go through all the setup steps, a Linux session save file is included with this post.<\/p>\n<p>Simply replace your existing save file with this one and you will be 99% complete with a web server that supports both php and mySQL server. <a href=\"http:\/\/internetofhomethings.com\/share\/precisesave-lampserver.zip\" target=\"_blank\">Here it is<\/a>. You can also refer to the <a href=\"#quickandeasy\">Quick and Easy<\/a> section of this post minimal installation steps.<\/p>\n<p>But if\u00a0you would like to understand the steps to installing \u00a0mySQL on the USB Puppy Linux setup, read on. Now let&#8217;s add the mySQL server\u00a0to the USB LAMP web server installation from\u00a0<a href=\"http:\/\/wp.me\/p5NRQ8-nB\" target=\"_blank\">part 2<\/a>\u00a0of this series.<\/p>\n<h3 style=\"text-align: center;\"><strong>Adding mySQL Server\u00a0to the USB Web\u00a0Server<\/strong><\/h3>\n<div style=\"color: red;\">IMPORTANT: The installation of mySQL Server will corrupt the save file. This will make it impossible to shut-down or start the USB Puppy Linux. Prior to proceeding, copy the save (*.sfs) file, located in the root USB directory (when viewed from Windows OS). It will be needed later to restore the Linux installation.<\/div>\n<p>Start the USB installed Precision Puppy Linux from <a href=\"http:\/\/wp.me\/p5NRQ8-nB\" target=\"_blank\">part 2<\/a>. Then launch the Puppy Package Manager. In the search window (Find), enter &#8220;mysql&#8221;.<\/p>\n<p><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/mysql_svr1.png\" rel=\"attachment wp-att-1515\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1515\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/mysql_svr1.png\" alt=\"mysql_svr1\" width=\"939\" height=\"667\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/mysql_svr1.png 939w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/mysql_svr1-300x213.png 300w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/mysql_svr1-768x546.png 768w\" sizes=\"auto, (max-width: 939px) 100vw, 939px\" \/><\/a><\/p>\n<p>From the list of results, select mysql-server-5.5-47 metapackage.<\/p>\n<p>Then click on &#8220;Examine dependencies&#8221;.<\/p>\n<p>When a window pops up, click on the &#8220;Download and install selected packages&#8221; button.<\/p>\n<p>Then click on &#8220;Download packages&#8221;.<\/p>\n<p>After the installation finishes, the following prompt appears:<\/p>\n<p><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/mysql_svr5.png\" rel=\"attachment wp-att-1517\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1517\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/mysql_svr5.png\" alt=\"mysql_svr5\" width=\"441\" height=\"397\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/mysql_svr5.png 441w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/mysql_svr5-300x270.png 300w\" sizes=\"auto, (max-width: 441px) 100vw, 441px\" \/><\/a><\/p>\n<p>In order to add\u00a0\u00a0the missing library, first close and then re-opening the Puppy Package Manager.<\/p>\n<p>This time, enter &#8220;libatm&#8221; in the find input. You will probably only find one results from searching all the repositories, &#8220;libatm1_2.5.1-1.3&#8221;.<\/p>\n<p>Select it and install the package as done for the mySQL server package.<\/p>\n<h3 style=\"text-align: center;\"><strong>Backing up the installed packages<\/strong><\/h3>\n<p>Now is the time to create a backup of the installed programs. Do not exit Puppy Linux until this is completed.<\/p>\n<p>First, install a blank USB memory stick of at least 4MB into the computer that is running Puppy Linux. This drive will appear as an added device in the bottom left of the Linux screen. Take note of the name assigned to this drive (it will be something like sdb1 or sdc1).<\/p>\n<p>From a console window, enter:<\/p>\n<p>cd \/<\/p>\n<p align=\"LEFT\"><span style=\"color: #000000;\"><span style=\"font-family: Verdana, Arial, Helvetica, sans-serif;\"><span style=\"font-size: small;\">mksquashfs etc root usr \/mnt\/&lt;drive name from above&gt;\/mybackup.sfs\u00a0<\/span><\/span><\/span><\/p>\n<p>Wait for the SFS file creation to complete.<\/p>\n<p>Now remove the added thumb drive and then hold down the PC start button until the PC shuts off.<\/p>\n<h3 style=\"text-align: center;\"><strong>Restoring the backed up configuration<\/strong><\/h3>\n<p>These steps need to be performed from a PC running\u00a0Windows OS.<\/p>\n<p>Using the same USB memory stick we have been using to prepare this setup, first copy the save file (see red text above) to the root directory.<\/p>\n<p>Then copy the &#8220;mybackup.sfs&#8221; file created above to the USB memory stick root directory.<\/p>\n<p>Now lets boot from the USB memory stick, which should start in the Puppy Linux OS again.<\/p>\n<p>NOTE: Make sure the PC you are using for this step has at least 4 GB of ram installed. I tried it with a 1GB netbook which failed the process after running out of RAM.<\/p>\n<p>Open two file browser windows (Menu-&gt;Filesystem-&gt;ROX-Filer).<\/p>\n<p>In one window, navigate to \/etc\/home\/mybackup.sfs. After clicking on the file, select &#8220;view&#8221;. A folder with the 3 backed up directories (etc root usr) will appear.<\/p>\n<p>In the other file manager windows, navigate to the top-level folder. Among the other directories, this window will also include etc, root, and usr. Copy the files from the first window to the second window.<\/p>\n<p>This can be done by pressing Ctl-A in a blank space in the first window (Selects the 3 folders) and dragging these selected folders to the second window.<\/p>\n<p>I found that a prompt to confirm the over-write of each file was required and could not figure out how to suppress it. Since there are thousands of files to copy, this requires many mouse clicks or pressing the enter key. As a work-around to automate this step, I used an object that was heavy enough to hold the enter key down. A bottle of essential oil worked well for my enter key.<\/p>\n<p>Use your imagination here!<\/p>\n<p><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/20160321_151721.jpg\" rel=\"attachment wp-att-1520\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1520 size-large\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/20160321_151721-921x1024.jpg\" alt=\"20160321_151721\" width=\"620\" height=\"689\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/20160321_151721-921x1024.jpg 921w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/20160321_151721-270x300.jpg 270w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/03\/20160321_151721-768x854.jpg 768w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/a><\/p>\n<p>And\u00a0here is where patience is needed. This copy process took over an hour to complete.<\/p>\n<p>Remember, a save file (*.sfs) is provided with this post which already includes these steps, so you don&#8217;t have to repeat this lengthy but necessary step.<\/p>\n<p>Once the copy is completed, restart the Linux computer. This should created a clean save file.<\/p>\n<p>Alas, we are ready to resume the mySQL installation!<\/p>\n<h3 style=\"text-align: center;\"><strong>Console Entries<\/strong><\/h3>\n<p>A few steps are now needed to complete the installation of mySQL. Open a console window and enter the following:<\/p>\n<p># mkdir \/var\/lib\/mysql<\/p>\n<p># adduser mysql<\/p>\n<p># chown -R mysql:mysql \/var\/lib\/mysql<\/p>\n<p># chgrp -R mysql \/var\/lib\/mysql<\/p>\n<p>#mysql_install_db<\/p>\n<p># mkdir \/var\/run\/mysqld<\/p>\n<p># chown mysql:mysql \/var\/run\/mysqld<\/p>\n<p>That&#8217;s it. The installation of mySQL Server is complete.<\/p>\n<h3 style=\"text-align: center;\"><strong>mySQL Server commands<\/strong><\/h3>\n<p>Here are a few console commands to run the server:<\/p>\n<p><strong>Start Server:<\/strong><\/p>\n<p># mysqld<\/p>\n<p><strong>Stop Server<\/strong> (Do this from a second console window):<\/p>\n<p># mysqladmin -u root -p shutdown<\/p>\n<p><strong>Change rood password:<\/strong><\/p>\n<p># mysqldadmin -u root password &#8216;new-password&#8217;<\/p>\n<p>or<\/p>\n<p># \/usr\/bin\/mysqldadmin -u root password &#8216;new-password&#8217;<\/p>\n<p><a href=\"http:\/\/www.tecmint.com\/mysqladmin-commands-for-database-administration-in-linux\/\" target=\"_blank\">Here<\/a> is a reference of other commonly used mySQL server commands.<\/p>\n<h3 id=\"quickandeasy\" style=\"text-align: center;\"><strong>Quick and Easy Setup<\/strong><\/h3>\n<p>And as promised,\u00a0I am providing a system image of the full USB LAMP installation in this section, so you can skip most of\u00a0the steps outlined above and in the first two posts of this series.<\/p>\n<p>Just follow these simple steps, eliminating most of the time-consuming setup:<\/p>\n<p>Step 1: Create a Linux USB Memory stick installation per the first part of <a href=\"http:\/\/wp.me\/p5NRQ8-n3\" target=\"_blank\">this post<\/a>. You can stop prior to installing Apache Server. That package is included with the *.2fs file referenced below.<\/p>\n<p>Step 2: Shut-down the Linux OS running from the USB stick. This will create a save file.<\/p>\n<p>Step 3: Boot a PC to Windows. Install the USB memory stick and delete the save (*.2fs) file from the root directory. Then copy the *.2fs file from <a href=\"https:\/\/www.dropbox.com\/s\/g4tfjpt31x9vot2\/precisesave-lampserver.zip?dl=0\" target=\"_blank\">this location<\/a> to the root directory.<\/p>\n<p><strong>NOTE: The file is contained in a ZIP compressed file. The compressed file is over 280MB in size and\u00a01GB uncompressed. Expect the download to require some time (17 minutes with my connection).<\/strong><\/p>\n<p>Step 4: Boot a PC with the USB Stick installed to Puppy Linux. This stick now has a complete LAMP stack. But you may need to adjust the IP and port of the server to your specific system. The defaults are IP=192.168.0.110 and port=9777.<\/p>\n<p>Step 5: <a href=\"http:\/\/wp.me\/p5NRQ8-n3#setip\" target=\"_blank\">Set the IP for your system<\/a><\/p>\n<p>Step 6: <a href=\"http:\/\/wp.me\/p5NRQ8-n3#setport\" target=\"_blank\">Set the listen port for your system<\/a><\/p>\n<p>Step 7: Reboot one more time to create your own save file.<\/p>\n<p>Be sure and review the 3 posts in this series as a guide to using this LAMP stack. A sample HTML and PHP file is provided in the root folder for web pages, \/var\/www<\/p>\n<h3 style=\"text-align: center;\"><strong>In Conclusion<\/strong><\/h3>\n<p>In these 3 articles, we have created a USB memory stick Linux environment and added an Apache Web Server, php and mySQL client libraries, and now the popular mySQL Server. Next, we will add phpmyAdmin as a basic tool for administering the mySQL database.<\/p>\n<p>As always, I hope you find this information useful&#8230;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A\u00a0web server is certainly not complete without a database server.\u00a0Currently, the one-source server of choice is mySQL. At first, adding this database server to my Linux setup\u00a0update appeared to be &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,19,3],"tags":[124,125,126,127],"class_list":["post-1510","post","type-post","status-publish","format-standard","hentry","category-alltheposts","category-internet-of-things","category-web-coding-tips","tag-cannot-shutdown-puppy-linux","tag-install-mysql-in-puppy-linux","tag-mysql-corrupts-linux","tag-quick-and-easy-usb-lamp-stack"],"_links":{"self":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/1510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1510"}],"version-history":[{"count":17,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/1510\/revisions"}],"predecessor-version":[{"id":1604,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/1510\/revisions\/1604"}],"wp:attachment":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}