MySQL in and around PLESK really useful commands

I’m always having to look up and figure out all this mysql stuff online. So I’m going to save my favourite commands here. I’ll try to include versions where I can…. Stay tuned.


OK, exporting ( dumping from a MySQL database ) in Plesk

mysqldump -uadmin -p`cat /etc/psa/.psa.shadow` –add-drop-table –add-drop-database  –default-character-set=latin1 mydb > db.sql

This bit `cat /etc/psa/.psa.shadow` grabs your PLESK MySQL password.

Add –add-drop-table if you’ll be exporting over an existing database or tables

Add –add-drop-database if you’ll be exporting over an existing database

mydb is the database you want to export from.

db.sql is the file you want to export to.


To import the file in to a database, connect to MySQL on your server

Go to the directory that has your db.sql file that you’re going to be importing

mysql -uadmin -p`cat /etc/psa/.psa.shadow` -p

Then enter the password

If you’re importing in to a new database:
The type in USE mydatabasename
Where mydatabasename is the name of the database you’re writing over

now type source db.sql;

remember to put the semi colon in there,
You should see a whole lot of
Query OK, 1 row affected (0.01 sec)
Lines, which is fine. Just wait it out and your import should complete all by itself.

SQL Server 200(x) useful commands

Now that I use SQL Server all the time, I thought I’d better start recording my "Oh that’s how it’s done, I wish I had that written down somewhere" Commands Moving a database from one machine to another. 1. Create the database on the new machine with the same name 2. Detatch it 3. Run this: use MyDBName

go sp_attach_db ‘MyDBName’,’C:\work\utilico\DB\MyDBName.mdf’,’C:\work\utilico\DB\MyDBName_log.ldf’ go 4. Done is born!

After, well many years now is finally in a nearly completed state. I like the dark colours, and the fact that it covers more to do with consultancy than web design. Since I spend most of my time doing consultancy work, it felt good to flesh out exactly what I do, instead of just saying ‘stuff with computers’. So if you want something done in IT, let me know!

Falling in love again ….

Last weekend, I fired up SQL Server 2005. It was an upscale of an MS Access backend I was using. And my god, did it seriously help me get my app working!!

I used SQL Server for some projects a few years ago, and even trained up in it. And with it’s stored procedures, triggers, user definable functions, cursors, and calcualted columns it rocks! And it’s got a really neat IDE. I’ve also just discovered that Access 2007 can edit SQL Server object nicely. Sweeeeet.

So, oh so much better than mysql. And this is from someone who’s been using mysql for 3 years now.

Mysql’s great as a content store for sites, but if you ever want to RAD an Application, use SQL Server!

Plesk visits

This site is actually getting some visits. I think it’s probably people looking for help with Plesk. I’ll continue to add to my useful list of commands. And other things that have worked for me. I’m not too impressed with plesk, but now that I know how to use it, I don’t want to switch to cPanel. So ladies and gentlemen, enjoy the Plesk show

5 Reasons why I really hate Ruby on Rails

The story of a suffering idealist.

Early in 2006, I realized my office needed a job tracking system. We’re a mac/pc office, so I wanted something that would work for both.

I decided to use a web based system. So we could eventually publish our job system to clients so they could see where they were up to.
After looking around for quite some time, I bought in to the hype around Ruby on Rails. After a few weeks stuffing around with config files, mysql databases and servers I managed to get a nice little scaffold up and running. I thought this was great, so much better than creating the system from scratch in php!!
And yes, Ruby on Rails is probably easier than php. But …

  1. It’s easier to start a new project, but as it grows, it gets exponentially harder. That right, like grains of sand on a chess board, item 7 of my project was twice as hard as item 6, which was twice as hard as 5.
  2. No real debugging. I’m a VB man. I’m used to the debugger in Access and VB. It’s a nice, warm forgiving debugger, so simple. I tried all sorts of Ruby on Rails setups, from Ruby in Steel, Eclipse and everything else that had an IDE on Rails. And they all sucked. Yes that’s right, they stank.
  3. Documentation? Forget it. Figure it out yourself, or ask on the forums. I bought 3 Ruby Rails books, and downloaded some more. Since my project was different to the ones in the books, I found their lessons very hard to apply to my situation.
  4. Enjoy being poor? Learn Ruby on Rails. Walk with me here … Ruby on Rails is free, that’s why I chose it. But because there’s little money behind it, there’s poor doco, bad support and only a few sites using it. ( compared to apache/php or iis/asp ). If you want money, go to a client who’s willing to spend money. Chances are they’ve already spent money. On microsoft systems!! So, learn Ruby on Rails and work for people who don’t want to spend money, or learn and work for people who have and will spend money!
  5. Certification? Forget it!! Another reason big companies won’t take on RoR is because, with no certification, they have no way of knowing if potential employers are any good. Period.

So, I gave up on RoR, grabbed a copy of Iron Speed developer for IIS, which is what RoR would like to be in about 10 years, and had a draft system up and running that was working better than what my RoR system was after 6 months. I’d like to use only open source software, and support it, and eventually write my own open source, but I’ve got deadlines, requirements and a limited attention span!
So, call me stupid, but Iron Speed rocks, and Ruby on Rails sucks!

Plesk, really useful commands

Ok, I’ve made a text file of all those tricky commands I use on plesk FC2. Many of them have saved my bacon, or just been really useful

cat /var/log/messages | tail -200
What has the server been up to? This message shows the last 200 lines of the servers log, it’s good to track down all sorts like dns errors and ftp errors.

tail /var/log/messages -f -n 14000 | grep ‘Jun 1′
Show server messages from a certain date ( June 1st )

du -sk*
Disk usage, there’s all sorts of variants, but this one’s me fav
chown -R user:group *
Changes the owner of files recursively

chmod -R 755 *
changes the permissions of files recursively

mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e’delete from PMM’
Fixes updater never stopping error

mysqlcheck -o -u admin -p`cat /etc/psa/.psa.shadow` –all-databases
Optimizes all tables

Here’s one for all those people having problems with character sets:
When using MySQL’s UTF-8 character set, besides setting the database character set to UTF-8, you must remember to send SET NAMES ‘utf8′ to MySQL prior to querying or inserting. Forgetting to do will surely cost you a substantial amount of hair, sleep, and sanity.
ps -aux
View all active processes

View processes live

/sbin/service httpd restart
restart apache

/sbin/service mysqld restart
restart mysql

tar -zxvf file.tar.gz
extract from a tar.gz file
Great place to see how to upgrade php and mysql

4psa total backup

Great backuping up tool for plesk. Much better than their scractchy one
Running plesk update from the command line

Debug Spam Assassin
spamassassin -D -lint

Good Resource for SpamAssassin

Update SpamAssassin on Fedora Core 4
yum install spamassassin

To use a proper anti spam setup
remove psa-spamassassin ( rpm -e psa-spamassassin )
yum install spamassassin
install dcc, pyzor and razor (,

Restart Spam Assassin
/etc/init.d/spamassassin restart

Get rid of ‘config: not parsing, administrator setting: pyzor_options –homedir /etc/mail/spamassassin//.pyzor’ messages
mv /var/qmail/mailnames///user_prefs /var/qmail/mailnames///user_prefs_old
then restart plesk

If you get ‘/var/dcc/map is not private’ in the logs.
As root run
chmod 0600 /var/dcc/map

If ftp upload session times out or drops out.
Turn off windows firewall on your computer, or turn off the application gateway service.

View mail logs after upgrading to 8.1
tail /usr/local/psa/var/log/maillog -f -n 2000

/usr/local/psa/admin/bin/modules/watchdog/rkhunter –configfile /usr/local/psa/etc/modules/watchdog/rkhunter.conf –update
force update of rkhunter ( rootkit hunter )

Quickly Install Zend 3.0 and then fix php
cd /usr/local/src
tar -zxf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
cd ZendOptimizer-3.0.1-linux-glibc21-i386

Now just hit enter a few times until it is done…
This guy is on the right track, what you need to do is cut out the [Zend] block of text from your php.ini file:


(usr/local/Zend/etc/php.ini as default) and paste it into a file in the /etc/php.d/ directory, you can name the file anything, i called mine zend.ini.

The problem arises because (like this guy said) ionCube will not allow php to run if theres a similar module loaded before it:

PHP Fatal error: [ionCube Loader] The Loader must appear as the first entry in the php.ini file in Unknown on line 0

and since ionCube is an include (in the php.d directory), and the zend code is pasted directly in the php.ini file, the zend code gets executed first. So as long as you move the zend code after the ionCube code, everything should work just fine… just remember, file includes with regards to php and apache are alphabetical, so if you name your file aaazend.ini it will still error out because it comes before ionCube-loader.ini (or whatever your ionCube file is called).

See what’s in the qmail queue:


Zip all files excluding some, use the -x option
zip -r httpdocs/ -x \*.zip