{"id":60220,"date":"2023-07-31T03:01:30","date_gmt":"2023-07-30T17:01:30","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=60220"},"modified":"2023-07-29T18:38:13","modified_gmt":"2023-07-29T08:38:13","slug":"linux-centos-web-server-domlogs-diskspace-issue-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-centos-web-server-domlogs-diskspace-issue-tutorial\/","title":{"rendered":"Linux CentOS Web Server Domlogs Diskspace Issue Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Apache\/domlogs_clear.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Linux CentOS Web Server Domlogs Diskspace Issue Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Apache\/domlogs_clear.jpg\" title=\"Linux CentOS Web Server Domlogs Diskspace Issue Tutorial\"   \/><\/a><p class=\"wp-caption-text\">Linux CentOS Web Server Domlogs Diskspace Issue Tutorial<\/p><\/div>\n<p>Running a Linux CentOS Apache\/PHP\/MySql web server has its ups and downs, the most visited issues for us involving diskspace in two ways &#8230;<\/p>\n<ul>\n<li>diskspace itself ( detectable via <i style=color:purple;>df -k \/<\/i> )<\/li>\n<li>diskspace related inode count limit ( detectable via <i style=color:purple;>df -i \/<\/i> )<\/li>\n<\/ul>\n<p>And so, as another chapter in our &#8220;diskspace management&#8221; saga, in a similar vein to <a title='MySql Repair Table Diskspace Error Log Consequence Tutorial' href='#msrtdelct'>MySql Repair Table Diskspace Error Log Consequence Tutorial<\/a> was the discovery yesterday, that <i>dk -k \/<\/i> remained at 97% <font size=1>(anything around 95% and above is not good)<\/font> well past an Apache Web Server service and MySql Web Server service restart (the time before this getting us back 3% of diskspace regarding logs) got us looking further afield.  We discovered huge logs in what we call the &#8230;<\/p>\n<blockquote><p>\nDomlogs area\n<\/p><\/blockquote>\n<p>These logs were gigabytes big, and got us wondering &#8230;<\/p>\n<blockquote><p>\n<a target=_blank title='\"can i delete logs in \/usr\/local\/apache\/domlogs\"' href='https:\/\/www.google.com\/search?q=%22can+i+delete+logs+in+%2Fusr%2Flocal%2Fapache%2Fdomlogs%22&#038;rlz=1C5CHFA_enAU973AU973&#038;oq=%22can+i+delete+logs+in+%2Fusr%2Flocal%2Fapache%2Fdomlogs%22&#038;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRigATIHCAIQIRigAdIBDjgzMTc0NjU4OWowajE1qAIAsAIA&#038;sourceid=chrome&#038;ie=UTF-8'>&#8220;can i delete logs in \/usr\/local\/apache\/domlogs&#8221;<\/a>\n<\/p><\/blockquote>\n<p> &#8230; and we were glad to <a target=_blank title='Useful webpage ... thanks' href='https:\/\/forums.cpanel.net\/threads\/usr-local-apache-domlogs.52717\/#:~:text=Clearing%20them%20out%20with%20a,if%20you%20type%20it%20wrong.'>get the tip<\/a> that we could do clearing, as long as we did not want information from out of these extensive logs <font size=1>(which you should look into yourself)<\/font> and that the mechanism should be a &#8230;<\/p>\n<ul>\n<li><font size=1>(what we like to call a)<\/font> &#8220;clobber&#8221; &#8230; rather than &#8230;<\/li>\n<li>&#8220;deletion&#8221;<\/li>\n<\/ul>\n<p> &#8230; in that a &#8220;clobber&#8221; is like &#8220;clear all the records in a file but keep its name and permissions always intact&#8221; <font size=1>( like, in SQL <i style=color:blue;>delete * from mytable<\/i> )<\/font> whereas a &#8220;deletion&#8221; on Linux often involves the &#8220;rm&#8221; command where the file itself disappears <font size=1>( like, in SQL <i style=color:blue;>drop table mytable<\/i> )<\/font>.  An example of a command <font size=1>(which got us going &#8220;aaaaahhh&#8221;)<\/font> was &#8230;<\/p>\n<p><code><br \/>\ncat \/dev\/null &gt; \/usr\/local\/apache\/domlogs\/rjmprogramming.com.au<br \/>\n<\/code><\/p>\n<p> &#8230; to get diskspace back and not affect the usual web server and RJM Programming domain website operations.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/linux-centos-web-server-domlogs-diskspace-issue-tutorial\/'>Linux CentOS Web Server Domlogs Diskspace Issue Tutorial<\/a>.<\/p-->\n<hr>\n<p id='msrtdelct'>Previous relevant <a target=_blank title='MySql Repair Table Diskspace Error Log Consequence Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/mysql-repair-table-diskspace-error-log-consequence-tutorial\/'>MySql Repair Table Diskspace Error Log Consequence Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/MySql\/mysql_repair_part_two.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"MySql Repair Table Diskspace Error Log Consequence Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/MySql\/mysql_repair_part_two.jpg\" title=\"MySql Repair Table Diskspace Error Log Consequence Tutorial\"   \/><\/a><p class=\"wp-caption-text\">MySql Repair Table Diskspace Error Log Consequence Tutorial<\/p><\/div>\n<p>If you are managing a web server, you can run into times when &#8230;<\/p>\n<ul>\n<li>a total solution to a problem needs more research that will take time &#8230; but, perhaps &#8230;<\/li>\n<li>there is a solution that &#8220;eases the pain&#8221; of web server management and operations, in our case, &#8220;diskspace&#8221; issues, awaiting that total solution<\/li>\n<\/ul>\n<p>So it was here at this RJM Programming CentOS WHM <a target=_blank title='Linux operating system information from Wikipedia, thanks' href='https:\/\/en.wikipedia.org\/wiki\/Linux'>Linux<\/a> dedicated Apache\/PHP\/<a target=_blank title='MySql' href='https:\/\/www.mysql.com\/'>MySql<\/a> web server, recently, as it ran out of diskspace, and we researched the issue, again, via the &#8220;old chestnuts&#8221; (at least for us) &#8230;<\/p>\n<ul>\n<li><a target=_blank title='Secure Shell information from Wikipedia, thanks' href='https:\/\/en.wikipedia.org\/wiki\/Secure_Shell'>ssh<\/a> session at command line &#8230;<\/li>\n<li>\n<code><br \/>\ndf -k \/<br \/>\n<\/code><br \/>\n &#8230; for overall disk diskspace reading &#8230; and, sidling up to a &#8220;base folder&#8221; of interest, via &#8220;cd&#8221; &#8230;\n<\/li>\n<li>\n<code><br \/>\nfind . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}<br \/>\n<\/code>\n<\/li>\n<\/ul>\n<p> &#8230; landed us on another file that appeared, but was not frontmost in our thinking, on that other day when we presented <a title='MySql Repair Table Failure Diskspace Consequence Tutorial' href='#msrtfdct'>MySql Repair Table Failure Diskspace Consequence Tutorial<\/a> to outline a MySql Table Failure Consequence to diskspace.<\/p>\n<p>Well, this &#8220;MySql Table Failure Consequence&#8221; has a second part to its story regarding diskspace.   Yes, in order to try for a &#8220;total solution&#8221; we attempt this <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/phpMyAdmin\/iFrame.html'>phpMyAdmin<\/a> &#8230;<\/p>\n<p><code><br \/>\nREPAIR TABLE wps_comments;<br \/>\n<\/code><\/p>\n<p> &#8230; SQL but it fails.  And though the WordPress Blog is functional, still, just because you go from <b>Defcon 5<\/b> to <font size=1>Defcon 1 <sup>3<\/sup>\/<sub>4<\/sub><\/font> in your &#8220;Systems Operator&#8221; thinking, then, doesn&#8217;t mean there aren&#8217;t other issues here!   Oh, <a target=_blank href='https:\/\/www.youtube.com\/watch?v=3Z0QUygjr2w' title='?'>no. no, no, no &#8230; yes<\/a>!<\/p>\n<p>That MySql table repair requirement is logged, but where?   Have a read of the excellent <a target=_blank title='Excellent MySql error logs information, thanks' href='https:\/\/www.oreilly.com\/library\/view\/mysql-reference-manual\/0596002653\/ch04s09.html#:~:text=err.,critical%20errors%20found%20when%20running.'>The MySQL Log Files &#8211; MySQL Reference Manual [Book]<\/a>, especially its section entitled &#8220;The Error Log&#8221;, as well as those &#8230;<\/p>\n<p><code><br \/>\nFLUSH LOGS;<br \/>\n<\/code><\/p>\n<p> &#8230; phpMyAdmin SQL that might come in handy!<\/p>\n<p>Yes, this &#8220;vs-rmetcalfe.au.syrahost.com.err&#8221;, for us here at RJM Programming web server, looked familiar?!   Yes, it appeared in the list of big files during the research and development mentioned in <a title='MySql Repair Table Failure Diskspace Consequence Tutorial' href='#msrtfdct'>MySql Repair Table Failure Diskspace Consequence Tutorial<\/a> &#8220;Part 1&#8221; below, but was not our focus that day.<\/p>\n<p>So, are we allowed to clear that log periodically, because we examined it, and it contained the same old records throughout, just with a different timestamp?  We did an experiment.  First, at the ssh command line, we went &#8230;<\/p>\n<p><code><br \/>\nmv vs-rmetcalfe.au.syrahost.com.err vs-rmetcalfe.au.syrahost.com.err-bad<br \/>\n<\/code><\/p>\n<p> &#8230; on the understanding that we could rename, back, should we cause MySql problems.  And, before the punchline, &#8220;mv&#8221; retains the &#8220;chown&#8221; and &#8220;chgrp&#8221; and &#8220;chmod&#8221; file permissions, happily, here.   Well, nothing bad happened.  Oddly, no new &#8220;vs-rmetcalfe.au.syrahost.com.err&#8221; was created, and that gave us an uneasy feeling, so we put things back to the way they were (renaming backwards) and saw the proper logfile grow again <font size=1>(sort of sadly and happily at the same time)<\/font>, but along the way we saw this &#8220;way backdated&#8221; and tiny &#8220;vs-rmetcalfe.per.syra.net.au.err&#8221; with appropriate file permissions from the old days sitting there, and so, tried &#8230;<\/p>\n<p><code><br \/>\ncp vs-rmetcalfe.au.syrahost.com.err vs-rmetcalfe.au.syrahost.com.err-bad<br \/>\ncp vs-rmetcalfe.per.syra.net.au.err vs-rmetcalfe.au.syrahost.com.err<br \/>\n<\/code><\/p>\n<p> &#8230; which resulted in &#8230;<\/p>\n<ol>\n<li>a &#8220;hived off&#8221; okay record of a set period of time in that &#8220;vs-rmetcalfe.au.syrahost.com.err-bad&#8221; file, left, existing, for future perusal, as required &#8230; as well as &#8230;<\/li>\n<li>a &#8220;non disrupted&#8221; scenario for MySql error logging, starting with that tiny 1 byte &#8220;vs-rmetcalfe.per.syra.net.au.err&#8221; start<\/li>\n<li>all file permissions and ownership as they should be &#8230; as well as, if you can imagine &#8230;<\/li>\n<li>do this at a particular time, once a day &#8230; cccrrrooonnntttaaabbb! &#8230; you get &#8230;\n<ul>\n<li>a day&#8217;s worth of MySql logging available for perusal (during office hours)<\/li>\n<li>maximum two day&#8217;s worth of logging diskspace used (at its worst just before the commands above, with added &#8220;-f&#8221; force switches are applied &#8230;<br \/>\n<code><br \/>\n54 4 * * * ksh -c \"cp -f \/var\/lib\/mysql\/vs-rmetcalfe.au.syrahost.com.err \/var\/lib\/mysql\/vs-rmetcalfe.au.syrahost.com.err-bad ; cp -f \/var\/lib\/mysql\/vs-rmetcalfe.per.syra.net.au.err \/var\/lib\/mysql\/vs-rmetcalfe.au.syrahost.com.err\"<br \/>\n<\/code><br \/>\n) &#8230; with the new <a target=_blank title='crontab information from computerhope ... thanks' href='http:\/\/www.computerhope.com\/jargon\/c\/cron.htm'>&#8220;crontab&#8221;<\/a> scheduling as above &#8230; as distinct from &#8220;? day&#8217;s worth, depending on web server uptime, which has been known to be as high as 90 days&#8221; diskspace being eaten up and eventually causing us web server failures all over the place\n<\/ul>\n<\/ol>\n<p>Ahhhhhhh!  <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/MySql\/mysql_repair_part_two.jpg\">What a relief<\/a>!<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/mysql-repair-table-diskspace-error-log-consequence-tutorial\/'>MySql Repair Table Diskspace Error Log Consequence Tutorial<\/a>.<\/p-->\n<hr>\n<p id='msrtfdct'>Previous relevant <a target=_blank title='MySql Repair Table Failure Diskspace Consequence Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/mysql-repair-table-failure-diskspace-consequence-tutorial\/'>MySql Repair Table Failure Diskspace Consequence Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/MySql\/repair_table_failure_issue.gif\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"MySql Repair Table Failure Diskspace Consequence Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/MySql\/repair_table_failure_issue.gif\" title=\"MySql Repair Table Failure Diskspace Consequence Tutorial\"   \/><\/a><p class=\"wp-caption-text\">MySql Repair Table Failure Diskspace Consequence Tutorial<\/p><\/div>\n<p>The previous <a title='MySql Repair Table Primer Tutorial' href='#msrtpt'>MySql Repair Table Primer Tutorial<\/a> outlined some <a target=_blank title='phpMyAdmin administrator for MySql database' href='https:\/\/www.phpmyadmin.net\/'>phpMyAdmin<\/a> administering of <a target=_blank title='MySql' href='https:\/\/www.mysql.com\/'>MySql<\/a> (database) maintenance via <a target=_blank title='SQL information' href='https:\/\/www.google.com\/search?q=sql&#038;rlz=1C5CHFA_enAU973AU973&#038;oq=sql&#038;aqs=chrome..69i57j0i67i131i433j0i67j0i67i131i433j0i67i433j0i67l2j69i65.1871j0j4&#038;sourceid=chrome&#038;ie=UTF-8'>SQL<\/a> like &#8230;<\/p>\n<p><code><br \/>\nREPAIR TABLE wps_comments;<br \/>\n<\/code><\/p>\n<p> &#8230; but what about if the SQL above fails or times out?  Well, there can be implications, as we discovered via <a target=_blank title='Useful link, thanks' href='https:\/\/stackoverflow.com\/questions\/25139332\/mysql-safe-to-delete-tmd-file#:~:text=The%20.,what%20happens%20just%20in%20case.'>this useful link<\/a>, thanks, that told us &#8230;<\/p>\n<blockquote cite='https:\/\/stackoverflow.com\/questions\/25139332\/mysql-safe-to-delete-tmd-file#:~:text=The%20.,what%20happens%20just%20in%20case.'><p>\nThe . TMD file is an intermediate data file for a table that needs to recreate its data file. So you can remove it because it&#8217;s normally used as a temporarly file but you could rename the file and check what happens just in case.\n<\/p><\/blockquote>\n<p>This advice prompted us to lookup a previous &#8220;diskspace concern&#8221; blog posting we&#8217;d written called <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/ITblog\/troubleshooting-centos-web-server-logfile-diskspace-issue-tutorial\/' title='Troubleshooting CentOS Web Server Logfile Diskspace Issue Tutorial'>Troubleshooting CentOS Web Server Logfile Diskspace Issue Tutorial<\/a>, its &#8220;take home&#8221;, always, for us, being that Linux statement &#8230;<\/p>\n<p><code><br \/>\nfind . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}<br \/>\n<\/code><\/p>\n<p> &#8230; gleaned via <a target=_blank href='https:\/\/superuser.com\/questions\/9847\/linux-utility-for-finding-the-largest-files-directories' title='Diskspace helper, thanks'>disk space \u2013 Linux utility for finding the largest files\/directories \u2013 Super User<\/a>, that has been so helpful for us over the years.<\/p>\n<p>You&#8217;ll see this command starring again with <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/MySql\/repair_table_failure_issue.gif\" title=\"Click picture\">today&#8217;s animated GIF presentation<\/a>, but you might wonder about where &#8220;diskspace&#8221; became our &#8220;theme of concern&#8221;?   Well, while the &#8220;REPAIR TABLE wps_comments&#8221; SQL was running we happened to have an RJM Programming ssh session going, monitoring &#8230;<\/p>\n<p><code><br \/>\ndf -k \/<br \/>\n<\/code><\/p>\n<p> &#8230; (for our Linux CentOS Apache\/PHP\/MySql dedicated web server) at regular intervals, and it started at 97% (used), but ballooned out to 99% (used), alarmingly, in that short, maybe, two minutes of monitoring!  So, again, thanks all you helpers and advisors out there on the net, helping us arriving to the position where we got 2% of diskspace back by removing that MySql TMD file caused by a failure with a &#8220;REPAIR TABLE&#8221; MySql SQL command!<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/mysql-repair-table-primer-tutorial\/'>MySql Repair Table Failure Diskspace Consequence Tutorial<\/a>.<\/p-->\n<hr>\n<p id='msrtpt'>Previous relevant <a target=_blank title='MySql Repair Table Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/mysql-repair-table-primer-tutorial\/'>MySql Repair Table Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/MySql\/RepairTable\/\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"MySql Repair Table Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/MySql\/RepairTable\/MySql_Recover-99of.jpg\" title=\"MySql Repair Table Primer Tutorial\"   \/><\/a><p class=\"wp-caption-text\">MySql Repair Table Primer Tutorial<\/p><\/div>\n<p>Today&#8217;s tutorial continues the MySql (command line) discussion last heard about with <a href='#moclpt' title='MySql Stored Procedures Primer Tutorial'>MySql Stored Procedures Primer Tutorial<\/a> as shown below, to illustrate that MySql has functionality to repair database tables, if they run into trouble.<\/p>\n<p>When you troubleshoot a problem regarding an Apache\/PHP\/MySql website you can tend to think, firstly, when a bit of functionality is not working (when it has been working fine for a while now) that the problem is with the software code being unable to cater with some unusual situation.<\/p>\n<p>The Apache log may get you closer to discovering the problem, but you may get to know some troubleshooting shortcuts, to rule out the database, or not, by checking the relevant database table using MySql from the command line, or the brilliant phpMyAdmin, as a GUI interface to the database.<\/p>\n<p>Not always, but sometimes, you can be surprised to find that MySql database tables do have problems from time to time, and that MySql marks these tables as <i>&#8220;crashed&#8221;<\/i>, as you can see in today&#8217;s <a target=_blank title='Click picture' href='http:\/\/www.rjmprogramming.com.au\/MySql\/RepairTable\/'>MySql Repair Table Primer Tutorial<\/a>.<\/p>\n<p>The functionality shown in the tutorial regarding phpMyAdmin MySql statement <i>REPAIR TABLE [tableName]<\/i> and the two MySql command line <i><a target=_blank title='mysqlcheck' href='http:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/mysqlcheck.html'>mysqlcheck<\/a><\/i> or, if MyISAM format, <i><a target=_blank title='myisamchk' href='https:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/myisamchk-repair-options.html'>myisamchk<\/a><\/i> choices are not guaranteed to fix the problem all the time, and sometimes it can be to do with the size of the table involved, or with the size of the temp area set aside on your server.  When a <i>REPAIR TABLE<\/i> operation runs too long, in phpMyAdmin the table will be still marked as crashed and you may see the string &#8220;(in use)&#8221; shown in the Collation column of the table screen.   In such cases you can:<\/p>\n<ul>\n<li>continue waiting for repair process to finish &#8230; or &#8230;<\/li>\n<li>use a restore operation to restore the table (that you have backed up recently) &#8230; or &#8230; (the next two options lose data, and so should only be done when you know the table is independent of others) &#8230;<\/li>\n<li>truncate the table with the phpMyAdmin &#8220;empty&#8221; icon (this may not work for a while, but becomes an option as time goes on) &#8230; or &#8230;<\/li>\n<li>drop the table (then recreate it) with the phpMyAdmin &#8220;drop&#8221; icon (this may not work for a while, but becomes an option as time goes on)<\/li>\n<\/ul>\n<hr \/>\n<p id=\"moclpt\">Previous relevant <a target=_blank title='MySql on Command Line Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=7031'>MySql on Command Line Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/MySql\/CommandLine\/\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"MySql on Command Line Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/MySql\/CommandLine\/MySql_CommandLine_Primer-9of.jpg\" title=\"MySql on Command Line Primer Tutorial\"   \/><\/a><p class=\"wp-caption-text\">MySql on Command Line Primer Tutorial<\/p><\/div>\n<p>Today&#8217;s tutorial follows up on <a href='#msppt' title='MySql Stored Procedures Primer Tutorial'>MySql Stored Procedures Primer Tutorial<\/a> as shown below, to illustrate that MySql database (and PHP server-side language) are friends of the command line, and you can use all these tools in <a target=_blank title='Batch processing information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Batch_program'>batch processing<\/a>, even though you most often associate PHP and MySql with interactive web use (or maybe you don&#8217;t?!).<\/p>\n<p>This blog talks a fair bit about batch processing and command line work, not so much from the point of view of nostalgia, but more from the point of view that lots of computer software functionality can still be modelled on a procedural set of tasks which can be planned so that interactivity stops at a certain point, and then you should let loose the power of the computer to actually do things (the joy of batch processing).   Do enough batch processing, and you feel what you feel like when you have trodden softly on this earth.<\/p>\n<p>Anyway, enough of the rave, but with the <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/MySql\/CommandLine\/\" title=\"Click picture\">tutorial<\/a> we interactively, on our local webserver&#8217;s <a target=_blank title='MAMP tutorials at this blog' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=MAMP'>MAMP<\/a> environment, create a new database called testdb, use the previous tutorial&#8217;s code to create some MySql tables and stored procedures in that database, so that we have one record in each of our two tables that we show you via phpMyAdmin (in an interactive way) and via a Mac OS X laptop&#8217;s Terminal application&#8217;s Linux bash environment command line (via the mysql program in a Linux command line environment).<\/p>\n<p>This example is simple, but you build off the simple, and imagine the big, and imagine the procedural, and imagine the compartmentalization of tasks &#8230; if you want to have fun that is &#8230; the bungee jumpers are all just faking it!<\/p>\n<p>So today, as well as with the previously relevant tutorial we used (MySql) stored procedures, and we&#8217;ll let Wikipedia explain this important database tool below.<\/p>\n<blockquote><p>A stored procedure is a subroutine available to applications that access a relational database system. A stored procedure (sometimes called a proc, sproc, StoPro, StoredProc, sp or SP) is actually stored in the database data dictionary.<\/p>\n<p>Typical use for stored procedures include data validation (integrated into the database) or access control mechanisms. Furthermore, stored procedures can consolidate and centralize logic that was originally implemented in applications. Extensive or complex processing that requires execution of several SQL statements is moved into stored procedures, and all applications call the procedures. One can use nested stored procedures by executing one stored procedure from within another.<\/p>\n<p>Stored procedures are similar to user-defined functions (UDFs). The major difference is that UDFs can be used like any other expression within SQL statements, whereas stored procedures must be invoked using the CALL statement.[1]<\/p><\/blockquote>\n<p>Thanks to <a target=_blank title='Database stored procedure information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Stored_procedure'>Wikipedia<\/a> for the quote above, and would recommend that if you want to get the most out of what is possible with databases, like MySql you also study triggers, and for that will leave you with a Wikipedia entry about this <a target=_blank title='Database trigger information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Database_trigger'>topic<\/a>.   Happy databasing!<\/p>\n<hr \/>\n<p id='msppt'>Previous relevant <a target=_blank title='MySql Stored Procedures Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=3849'>MySql Stored Procedures Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/MySql\/StoredProcedure\/MySql_StoredProcedure_Primer.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"MySql Stored Procedures Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/MySql\/StoredProcedure\/MySql_StoredProcedure_Primer.jpg\" title=\"MySql Stored Procedures Primer Tutorial\"   \/><\/a><p class=\"wp-caption-text\">MySql Stored Procedures Primer Tutorial<\/p><\/div>\n<p>Today&#8217;s tutorial follows up on <a href='#pitmappt' title='phpMyAdmin interface to MySql and PHP Primer Tutorial'>phpMyAdmin interface to MySql and PHP Primer Tutorial<\/a> in that we again use the brilliant phpMyAdmin to oversee the results of some PHP code which uses MySql calls to create tables called POINT and CIRCLE used to store information defining a circle, and then it creates three MySql stored procedures in the database to help add circle data with the single MySql statement that goes <em>CALL AddCircle(x, y, radius);<\/em> via the use of those stored procedures.   Let&#8217;s see below what <a target=_blank title='Stored Procedures information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Stored_procedure'>Wikipedia<\/a> says about Stored Procedures generally.<\/p>\n<blockquote><p>A stored procedure is a subroutine available to applications that access a relational database system. A stored procedure (sometimes called a proc, sproc, StoPro, StoredProc, sp or SP) is actually stored in the database data dictionary.<\/p>\n<p>Typical use for stored procedures include data validation (integrated into the database) or access control mechanisms. Furthermore, stored procedures can consolidate and centralize logic that was originally implemented in applications. Extensive or complex processing that requires execution of several SQL statements is moved into stored procedures, and all applications call the procedures. One can use nested stored procedures by executing one stored procedure from within another.<\/p>\n<p>Stored procedures are similar to user-defined functions (UDFs). The major difference is that UDFs can be used like any other expression within SQL statements, whereas stored procedures must be invoked using the CALL statement.[1]<\/p><\/blockquote>\n<p>Here is some downloadable PHP programming source code which shows the results of the MySql SQL requests made and can be renamed to <a target=_blank title='ourmysqlstoreprocedure.php' href='http:\/\/www.rjmprogramming.com.au\/MySql\/StoredProcedure\/ourmysqlstoredprocedure.php_GETME'>ourmysqlstoredprocedure.php<\/a> as required.<\/p>\n<p>Here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made and can be renamed to <a target=_blank title='ourmysql_storeprocedure.php' href='http:\/\/www.rjmprogramming.com.au\/MySql\/StoredProcedure\/ourmysql_storedprocedure.php_GETME'>ourmysql_storedprocedure.php<\/a> as required.<\/p>\n<p>If you want to develop your own live usage (have provided a live usage link <a target=_blank title='live usage or to see the raw MySql SQL involved in this tutorail' href='http:\/\/www.rjmprogramming.com.au\/MySql\/StoredProcedure\/'>here<\/a> which will not work but you can use if you are a beginner, to get used to mysql errors, which will occur after you hit either button of the link (these errors indicate bad MySql connection details which are the same reason the database dropdown is not full of options), or you can use this link to see the raw MySql SQL involved in piecing this tutorial together) of these two PHP source codes then you could fix up the hard codings for MySql host\/username\/password up the top of ourmysql_storeprocedure.php (where you may notice that the default host in the code is localhost:8889 which is the default host string for MySql (ie. <a target=_blank title='port explained by Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Port_%28computer_networking%29'>port<\/a> 8889 is used) when using a <a target=_blank title='PHP and MySql via MAMP Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=933'>MAMP<\/a> (Mac laptop) local web server (which uses localhost:8888 as its local &#8220;domain name&#8221; for http usage)) or you can keep the same code and use a URL like:<\/p>\n<p>[your-domain-name-plus-a-bit-maybe]\/ourmysql_storeprocedure.php?host=[your MySql host address]&#038;username=[your MySql username]&#038;password=[your MySql password]&#038;database=[your optional MySql default database name within the looked up list presented]<\/p>\n<hr \/>\n<p id='pitmappt'>Previous <a href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=492' title='phpMyAdmin interface to MySql and PHP Primer Tutorial'>phpMyAdmin interface to MySql and PHP Primer Tutorial<\/a> is relevant and shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/phpMyAdmin\/iFrame.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"phpMyAdmin interface to MySql and PHP Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/phpMyAdmin\/phpMyAdmin.jpg\" title=\"phpMyAdmin interface to MySql and PHP Primer Tutorial\"   \/><\/a><p class=\"wp-caption-text\">phpMyAdmin interface to MySql and PHP Primer Tutorial<\/p><\/div>\n<p><strong><\/p>\n<p>Transcript:<\/p>\n<p><\/strong><\/p>\n<p>You never hear much about the data when you hear about great PHP products, but we<br \/>\n   all know it is the data that differentiates the quality of the end result.<\/p>\n<p>That is probably because database products like MySql, SqlServer, Oracle SQL, Advantage and Access<br \/>\n   are pretty good at what they do, and emphasise reliability rather than flashiness.<\/p>\n<p>MySql and PHP have a great open source interface with phpMyAdmin, which is so good,<br \/>\n  you forget that it is not the default MySql administrator&#8217;s interface product.<\/p>\n<p>Let&#8217;s have a look at this WordPress database and a bit of how it looks, looking<br \/>\n  through the prism of  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/phpMyAdmin\/iFrame.html'>phpMyAdmin<\/a> &#8230;\n<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d492' onclick='var dv=document.getElementById(\"d492\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=47\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d492' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d3849' onclick='var dv=document.getElementById(\"d3849\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=47\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d3849' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d7031' onclick='var dv=document.getElementById(\"d7031\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=47\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d7031' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d7217' onclick='var dv=document.getElementById(\"d7217\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=47\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d7217' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d56880' onclick='var dv=document.getElementById(\"d56880\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/diskspace\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d56880' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d56974' onclick='var dv=document.getElementById(\"d56974\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/crontab\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d56974' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d60220' onclick='var dv=document.getElementById(\"d60220\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/log\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d60220' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Running a Linux CentOS Apache\/PHP\/MySql web server has its ups and downs, the most visited issues for us involving diskspace in two ways &#8230; diskspace itself ( detectable via df -k \/ ) diskspace related inode count limit ( detectable &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-centos-web-server-domlogs-diskspace-issue-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,37],"tags":[85,191,195,233,234,270,2346,355,4411,707,716,4085,2418,886,1319,1411],"class_list":["post-60220","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-apache","tag-cat","tag-centos","tag-command","tag-command-line","tag-cpanel","tag-diskspace","tag-domain","tag-domlogs","tag-linux","tag-log","tag-log-file","tag-management","tag-operations","tag-tutorial","tag-web-server"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/60220"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=60220"}],"version-history":[{"count":8,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/60220\/revisions"}],"predecessor-version":[{"id":60228,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/60220\/revisions\/60228"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=60220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=60220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=60220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}