A few days ago we talked about the great “Fred and Ginger” type of relationship PHP and MySql have with Apache web servers, in particular, with WordPress Upgrade Crontab Curl Tutorial.
Well, even Fred and Ginger had a bust up or two, so we’re not here to welcome a bust up, just to show the independence of MySql as a database tool.
The thing is, MySql can live with just Linux or Unix shell scripting, or with other languages also, and we show that a bit today, by showing a subset of the functionality of the previously discussed WordPress Upgrade Crontab Curl Tutorial functionality just using a Linux web server Korn Shell environment calling on MySql command line usage.
Admittedly, this is a bit beside the point, because we query (and join) two WordPress (.org) databases, and, as you know, or would glean by being an avid reader of this blog, WordPress is PHP and MySql itself. However, the possibilities are there to …
- install MySql on a Linux or Unix system
- create some database tables to a job specification of interest either programmatically (with Korn Shell, for example) or using the MySql command line, or perhaps (to cheat our mostly non-GUI feel today) use the preposterously humorous, engagingly intuitive, curiously avante gard, absorbingly refreshing, and the (oh all right you asked for it) curiously refreshing “phpMyAdmin” to do this
- write shell scripts (eg. Korn Shell) to query and manipulate the MySql database via command line MySql functionality (as we do today)
So, who’s been left out of the equation out of Fred and Ginger? I’d hate to say. Who’s really up front and loud, rather than behind-the-scenes and reliable, as databases tend to be?
Who’s getting sidetracted sidetracked man person?
Oh, THEM … okay then … but seriously, when you tackle a job with data, you need to weigh up some considerations …
- Is it a big data job now, or into the future? If yes, then this is better as a database job of some sort, rather than resorting to file systems of the web server you are on. If not, then it is overkill, in my opinion, to use a database like MySql, as it contributes highly to the load on your web server.
- Is the data hierarchical by nature? If yes then a relational database like MySql could do well, with a good design, that uses indexes on (ideally integer) numerical indexes.
- Will you need to be able to transport the solution to some other system that could be vastly different? Again, here, we wonder whether there is a lot of data, and if the answer is “No” then you should just adopt a web server file arrangement of some sort to best have the chance of an easy handover to another system. However, if there is some several megabyte size to the project with data, then the next best approach is to research what database works quite well in both operating system environments you are expecting.
Will leave you today with the Korn Shell script to query the two WordPress databases here for those mismatch “?p=[postId]” scenarios we talked about with WordPress Upgrade Crontab Curl Tutorial (and just writing for the first solution of the two solution ideas mentioned there), and you could call this code old_new_wp_mismatch_id.ksh if you like … but if you are feeling ornery and objectionable … can we recommend a session with the preposterously humorous, engagingly intuitive, curiously avante gard, absorbingly refreshing, and the curiously refreshing “phpMyAdmin” … just to lift the spirits … ahhhhhhhlll drink to that!
The way the code handles the MySql username’s password is to store it in a file outside the scope of the web server’s Document Root to put off “prying eyes”. There is a lot more you could do regarding encryption thoughts here, and with MySql command line it is not recommended to use its -p [password] switch, but rather interactively ask for the password, and that is effectively what we are doing by redirecting the MySql interactive input to this file outside the web server’s Document Root.
If this was interesting you may be interested in this too.
11 Responses to Korn Shell and MySql Primer Tutorial