If you do any sort of web development, it is more than likely that CPANEL and phpMyAdmin are good friends of yours…and you depend on them. Even though those are extremely handy to create/modify databases and create backups, it is extremely helpful to know how to do the same thing by using only SSH and command line utilities.
To backup (export) a database using the command line interface (CLI):
mysqldump -p --user=username --add-drop-table database > backup.sql
You will then need to provide your database password and the exported data will go into a file called “backup.sql” which is located in the directory that you are currently in. (more mysqldump documentation
To backup your files:
tar -cvzf backup.tgz directoryname
The command will create an archive of all your files so you can easily move or store one file (the archive). More tar documentation.
I have run into some database problems over the years, but had to do something different today when I saw that this site had a problematic table (wp_posts). When I looked at the issue first, I got the message “MySQL error code 145 = Table was marked as crashed and should be repaired”.
To repair a table, I have run (at a mysql prompt in the command line): REPAIR TABLE wp_posts; but today that did not work. After doing some research, I finally was able to fix the table by using: myisamchk -r wp_posts (see documentation. This was a lifesaver!
Finally after two years of contemplating the updates to Apache 2.x, MySQL 5.x, and PHP 5.x, I finally updated my server to the latest version os Apache, MySQL, and PHP. I was not too concerned about custom work or any of my WordPress sites, but I was concerned XOOPS and/or XOOPS modules would have some problems, but it is now a week later and everything is running smoothly. Why finally? Well, as of the end of this month, support for PHP 4 will be discontinued. Better late than never. Time to update your servers too?
If you all the sudden get database errors (select, cannot login, cannot write, etc) – and everything looks ok (from the database end of things) check to make sure you have not run out of disk space. How do I know? Well – let’s say last night I had to do a major fall clean-up. If you know me and my monitoring habits, this will sound a bit confusing because one of the many things I monitor is disk space, but when your hosting company accidentally halves your disk space – trouble can occur, and quickly. I have not had many issues at all with Liquid Web – but this was major…and handled a little slower than I would have liked.
After several days of researching and reading about how to solve a MySQL replication problem, I found a great resource on MySQL I thought I would share: MySQL Tips.
After working with Ben for almost eight years he had decided to move on. I wanted to wish Ben all the luck in the world. We had a great time working together for many years…as he put up with my on again off again relationship with Mac OS X Server and I put up with his “not as funny as he thought” videos and comics We also had a good time playing Carmageddon 2, Diablo, Diablo II and Quake 3 Arena. We did do some great work in between all the games and great music (I got him out of the “ambient” music mode and opened the door to electronica, DJs, etc). We did do a kick ass job of putting together a really sweet Mac OS X/Mac OS X Server server set up using Apache, MySQL, PHP, WebObjects complete with failover. Best of luck and thanks for the good times.
After talking to Scott I finally have a plugin which I am excited to develop and excited to share with the WordPress community…a plugin that will allow WordPress admins to see exactly how many people are subscribing to your WordPress RSS feed and who these people are. Why would I do this when Feedburner is out there (and I used it currently)? I like Feedburner but I do not like redirecting my RSS feed to a non jappler.com URL because I want to be in control of my own stats.
Why start with this? Scott had mentioned this to me and it sounded very interesting. With this project, I will be able to learn quite a bit about PHP, the WordPress API, MySQL, as well as RSS. This past weekend, between meetings, I read the documentation I blogged about yesterday and I started reading PHP and MySQL Web Development, which Scott recommended. I hope others will find this useful! I plan to really dig into this in the next few days. I am going to set up my test WordPress setup tomorrow so I can begin messing around with project.
For more information on this, check out Scott’s podcast on learning PHP and this project.
[tags]WordPress, rssStats, PHP, MySQL, RSS[/tags]
A big thanks to Scott for pointing me in the right direction. I just got back from the store with the huge book he recommended – PHP and MySQL Web Development. I plan to start work on my first “from scratch” WordPress plugin in the next few days.
[tags]PHP, MySQL, WordPress[/tags]
What got me up early Saturday and then up at 1am on Sunday? Server hardware failure…which led to some database corruption. I have never had to deal with database corruption, so I did not even know my problem was database corruption until after calling the helpful tech guys at Liquid Web. (I am not one to usually call tech support, but at 136am on a Sunday…I did not feel like spending time at mysql.com or google.com.)
I first noticed something on Saturday morning, but after restoring a database table from a backup, everything was golden. I told myself…it had to have been from some user error. Monday morning, after my Nagios server paged me, I noticed that jappler.com had several mysql
fetch_row () errors after the server came back up. I decided that this problem was not user error and something else was going on. As soon as I told the tech guy the error that I was seeing onjappler.com and other web sites I manage, he asked me if I had tried “repairing” the databases. I had not even thought about it (especially so early in the morning). Once he “repaired the databases”, everything was perfect.
This was a stressful lesson to learn, but I am always happy to learn new things. The lesson I learned was about database corruption. (All my tables are MyISAM)
[tags]MySQL, database corruption, CPANEL, MyISAM[/tags]
After finally getting some to to set up my development environment, I began thinking…why am I not using Apache 2.2 and PHP 5.1.2? What made me think about this? “Legacy Release” The phrase “legacy release” is what httpd.apache.org described Apache 1.3.x as in their news section. I have been using Apache 1.x for several years now, only ever really thinking about migrating to 2.0 because of the need to run a subversion server. I have a solid web server solution in place that has made me very happy for the last few years using Apache 1.3.x, but it is finally time to check out something in the 2.x family, and I am going to make that 2.2. I am going to spend some time tomorrow reading about any known issues (especially with PHP, as I remember that being a show stopper for my interest in 2.0 before) and then install/configure it. Stay tuned for some tutorials on what I did to get everything up and running!
[tags]apache, php, mysql, subversion[/tags]