Below you will find pages that utilize the taxonomy term “MySQL”
FreeBSD 7

FreeBSD 7 is available, many new improvements performance and feature wise, check the announcement.
One of the most impressive improvements is SMP (Symmetric multiprocessing):
Dramatic improvements in performance and SMP scalability shown by various database and other benchmarks, in some cases showing peak performance improvements as high as 350% over FreeBSD 6.X under normal loads and 1500% at high loads. When compared with the best performing Linux kernel (2.6.22 or 2.6.24) performance is 15% better
Drupal 6 released

Drupal the open source content management system has a new fresh release Drupal 6.
Update: It seems CCK and VIEWS aren’t compatible with Drupal 6 yet, does anyone use Drupal without CCK and VIEW?
CodeIgniter setup tips
- Fix mod_rewrite to have clean URLs, and get rid of “index.php” part.
- Edit “config/config.php” and change the following:
// Setup your base URL
$config['base_url']="http://rayed.com/ci/";
// No need for index.php
$config['index_page'] = "";
// Remove AUTO and Put PATH_INFO
// this will allows you to pass variables as URL
// segments or Query string "?id=1"
$config['uri_protocol'] = "PATH_INFO";
- Setup your database configuration “config/database.php”
- Auto connect to database, edit “config/autoload.php”:
$autoload['libraries'] = array('database');
- Edit “config/routes.php” to change default controller:
$route['default_controller'] = "users";
CodeIgniter yet another PHP framework

For the last year I spent a lot of my PHP time playing with CakePHP I like it at first, but when I tried to build large applications with it I noticed it have major issues with performance, plus I really had difficult time dealing with it is strict naming convention and it object-relational-mapping (ORM).
Few days ago I read about CodeIgniter framework and its similarities to CakePHP and its amazing performance, so I went and visited their website again, I heard about CodeIgniter before from Abdullah Aldosari (I miss our technical discussions) but when I visited the website I wasn’t really impressed, but the new website looks much better, so judging by the look improvement alone I decided to give it a try 🙂
Learning Drupal

Every Eid vacation I end up with an extra free time, I usually use it to learn new stuff, the latest vacation I decided to learn Drupal. Drupal is a Content management system (CMS), it is basically a software to help you manage your content.
Drupal is a modular and customizable CMS, you can use it to build different types of web sites, a Blog, company or organization web site, community website, you name it.
MySQL: fixing errors of the past
Old MySQL versions didn’t have good support for Arabic, so what I used to do is to configure MySQL tables with any character set e.g. latin-1 and configure PHP to read it and write in Windows-1256 and pass it to MySQL as is i.e. MySQL think it is “Latin-1” but in fact it is “Windows-1256”.
Needless to say cheating in the character set have many bad consensuses:
- Sorting will not work as expected
- Other applications will assume you are using the correct character set and you won’t be able to read or write your data. e.g. PHPMyAdmin could display something like this:
“ÈÓã Çááå ÇáÑÍãä ÇáÑÍíã”
How to fix it
I found this trick in MySQL documentation, what you need to do is convert any character field to “blob” then convert it back to the desired field type with the desired character set:
ALTER TABLE t1 CHANGE c1 c1 BLOB;
ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET cp1256;
You can change it and test it from phpMyAdmin.
Moved to a new server
rayed.com to new server with upgraded softwares:
FreeBSD 6.2
Apache 2
PHP 5
MySQL 5
Dovecot 1.0.0 released (Mail Server)
Dovecot version 1.0.0 finally released, after almost 5 years of development.
Dovecot is IMAP and POP3 server, it is one of the best and easiest servers I ever worked with, easy enough for home environment, and flexible and powerful enough for service providers.
I’ve tested it earlier before and hopefully we will migrate to it later this year.
Dovecot integrate very well with Postfix mail server (Postfix handle SMTP, Dovecot handle POP3+IMAP), and can easily support virtual hosting.
Alriyadh.com previous polls
Recently I have improved alriyadh.com voting system, many of them are in administration area, some of these changes will be visible in the near future.
One of the new additions is the previous votes page:
http://www.alriyadh.com/php/vote/
Check it out, and keep in mind the design is still under work.
Memo to self: replace the word “vote” with “poll”
UPDATE: If you see weird colors in IE (7?) it is fixed now.
Things I want to write about but don’t have time
These days I really don’t have time on the Internet, but I really want to talk about some of these issue in more depth later.
- My phone line (including DSL service) is out of service for more than month, and until now no hope 🙁
- IGW the new ISU: STC is now handling Internet gateway operation, the service is still has some issues, and we are still understaffed.
- Dev4Islam: Project to devlope open source Islamic and Arabic software and services. We aim to collect data and make it available for other so they can build better software.
- Java + Delphi = C# Anders Hejlsber the creator of Delphi, create a great language for Microsoft.
- Lucene is a full text search library, exteremly fast, and the API is awsome. I tested it Lucene .Net port it is really super fast.
- Swish-e same as lucene, this what I use for Alriadh.com, still very good.
- Alriyadh.com new feature: user login for better experince, no need to rewrite your name and email when you want to submit a comment or send article to a friend, and you can bookmark your favourite articles, any thing else we should add.
Virtual FTP accounts with Pure-FTPd and MySQL
Pure-FTPd is a FTP server with many features that enable you to host virtual accounts, these are the features that I loved and tested:
- You can put the user information in MySQL database, without having to create a real UNIX account for each user.
- It also have the feature of creating the user home directory when the user logging, so all you need to create a new user is to add it to the database.
- CallUploadScript this feature will make the server run a script whenever a new file is uploaded, I used this feature to scan the file for viruses as soon as the user upload the file. (I use ClamAV as my virus scanner)
Installation (FreeBSD)
# cd /usr/ports/ftp/pure-ftpd/
# make install
# vi /etc/rc.conf
:
pureftpd_enable="YES"
pureftpd_upload_enable="YES"
pureftpd_uploadscript="/path/to/pureftpd_uploadscript.sh"
:
Optimizing MySQL
The last 3 days we were facing many problems with Alriyadh.com web server, the server suddenly get very slow, and all requests times out. It took me very long time to identify the problem, I tried many things and every time I think it will solve the problem completely, but after few hours the problem appear again and he server start to crawl.
Until this moment I am not 100% sure the problem is solved, but during the process I learned many things, so I’ll share it with you and hopefully everything will go smoothly, if it doesn’t I have to learn new thing to figure out the problem.
Caching: memcached vs MySQL
Several month ago I researched caching methods to use with Alriyadh.com, it was essential because we used old and slow hardware.
The result of my test showed that MySQL based caching was superior to memcached caching.
I did a new benchmark comparing MySQL, PHP memcache extension, and PHP memcache class.
The text is done by fetching the result of a complex query 1000 times, and calculated the time it took using my bechmark library (link dead!), times in seconds:
PostgreSQL and PHP (on Windows)
After installing PostgreSQL (15 minutes job), and playing with pgAdminIII, I decided to try it with PHP.
PostgreSQL 8.1 released
PostgreSQL (Wikipedia) 8.1 released, check What’s new in 8.1 document.
For some reason I love PostgreSQL althought I never really used it before, I am very happy with MySQL but I really would love to use PostgreSQL, for me MySQL excel in 3 areas:
- PHPMyAdmin: I can’t live without it, I know PostgreSQL have phppgadmin, but I don’t think it would match PHPMyAdmin.
- Windows port: I remember they ported PostgreSQL to Windows, a while ago but I never tried it either, I guess I am lazy.
- Replication: I am not sure about the status of replication in PostgreSQL, am I lazy or what.
Caching method compared
I tested different types of caching, here is my times:
Method | Hit Time | Improvments over Miss |
---|---|---|
File | 0.00029 | 19337.93% |
MySQL | 0.00064 | 8762.50% |
memcached | 0.00103 | 5444.66% |
Altought File caching is much faster that the other two methods, it can suffer from file locking problems, and can’t be shared between more than one server.
memcached client used is written in PHP which will slow it down a little bit.
So MySQL seems the ideal choice 😉
PHP Accelerator is awesome
I have a server with PHPAdsNew installed serving around 20 requests per second serving a really busy web site.
Few days ago the admins for that website doubled the number of ads per page, and the server stopped responding most of the day 🙁
I installed PHP Accelerator to make it faster to serve the those ads, but it didn’t help that much, I tried every trick I know to maximize MySQL performance (although it didn’t have any load in the first place) nothing worked.
Change PHPMyAdmin to view Arabic on English interface
I love phpmyadmin, it is a web interface for MySQL DB server, I usually use the English interface, but the problem with English interface that it doesn’t show Arabic string, of course you can change the whole interface to Arabic, but I don’t understand anything from that interface.
So I played with PHPMyAdmin code so I can use English interface but using Arabic character set, here is how to do it:
# vi lang/english-iso-8859-1.inc.php
... change: $charset = 'iso-8859-1';
... to: $charset = 'windows-1256';
MySQL replication is so simple
I just configured my first MySQL replication, it is very simple to configure, few configuration steps and it is done.
The hardest thing is to figure the location of MySQL configuration file my.cnf under my FreeBSD, it doesn’t exists by default so you have to create it your self, it can be many place, I choosed /var/db/mysql/my.cnf to make reside with the datafiles.
You can find a sample chapter from Jeremy Zawodny book, High Performance MySQL.