MySQL not loading in PHP on Windows

There seems to be bug in MySQL 5.0.41. I stumbled across this when I tried to install a new isntallation of wordpress with the up to date versions I keeps getting a message “cannot load MySQL extension, please check PHP Configuration”. You can verify this also by running the following command: “php -m”. If you recieve a message lett ing you know that it can not load the MySQL dynamic library then this might be your problem. this is a know bug documented here:

http://bugs.mysql.com/bug.php?id=28358

problem: MySQL no loading in PHP

Fix: download a recompled version of libmysql.dll at:
http://www.tomdonovan.net/download/libmysql_5.0.41_Win32.zip
Replace all instances on your system.

thanks to the much smarter MySQL folks for this temporary fix.

MySQL backup for a Windows Administrator

As a windows Administrator we are asked to deal many varying technologies. Not all of them are native to the Windows platform, but are rather ports from the Linux world. While in most cases we are not asked to generally do nothing more than install and let the customer then customize as they see fit every once and a while your are asked to make backups for various reasons.

It is important to understand much like MS SQL, MySQL uses live data files that are constantly open. While there are some good choices in the MS SQL world for live backups the same can’t be said for MySQL. Therefore it is essential to create a flat file that most backup programs can store in case of emergencies.

I will step through creating a full MySQL database back up via an external program called ‘mysqldump’. The action is often referred to as a data dump. Using this technique not only creates a backup of your data but the associated structures that the data is held in. This makes it very easy to move in case such an even is needed.

Problem: create a complete flat file backup for MySQL

Fix: Open a command line window. type the following command: ‘ –opt –user=root mysqldump –all-databases > backup.sql’

Drive mapping in Terminal services

Today a client asked how they could drag and drop files when connecting to their Windows 2003 server. I responded with the normal, “you can do this by connecting to your FTP server on a Windows server…”. They were not thrilled. When dealing with a wide variety of clients you run the gambit of skill levels and effort.

Generally, they want things to be as easy as possible with a little complication as possible. Unless of course this violates security policies. In most cases your job is to balance what benefits your client versus the potential pitfalls. In the case of the new Windows remote desktop this was easily accomdatated.

Problem: securely transfer files will as little hassle as possible
Fix: enable ‘drive mapping’ for terminal services
How to:

1. Open Terminal services configuration\connections (tscc)
2. open the ‘navigation’ folder’
3. Open the properties for ‘RDP-Tcp’
4. click on the ‘client settings’ tab
5. clear the ‘drive mapping’ option box
6. click okay
7. close tscc

The next time your client logs in they will see their local drives mapped as part of the server’s additional drives. Now they can cut-n-paste with ease and still keep the secure connection.

NOTE: there are added notes here:  Drive mapping in Terminal services part 2

MySQL change root password for Windows

In a shared environment you are asked to tackle many strange tasks and not so strange tasks. Among my many common tasks that I’m asked to look into is management of MySQL on a windows platform. While there are plenty of instructions on how to manage MySQL in a linux environment there are little such documentation for a Windows platform.

I won’t go into the merits of MySQL on a Windows or Linux platform. As a system administrator you are asked to manage and fix problem not decided what is the best course of action.

To reset a root password in Windows is not really not much a difficult task so I’ll out line it here:

Problem: lost root password for MySQL windows implamentation
Fix:

  1. Stop the MySQL services
  2. open a command window and use the following command: “C:\<wherever_you_installed_MySQL>\bin\mysqld-nt –skip-grant-tables”
  3. open a second command window and user the following command: “c:\mysql -u root”
  4. This will start MySQL command line interface, now type: “use mysql;”
  5.  Next type in: “update user set password=PASSWORD(“some_new_password”) where Use=’root’;”
  6. now type in: “flush privileges;”
  7. finally: “quit”

You will have to restart the Windows server, but once this is complete you would have reset the MySQL root password.

PHP POST coding issues

As a system administrator you deal with many technologies. Alot of the times you don’t feel like you have a total grasp as you feel you should to properly should in order to be an effective adminstrator. For me this is PHP. While it has been around a while this particular technology is usually in the realm of the web developer. As in most things it does require adminsitrtors to know at least some things when the delevoper gets stuck on a particular problem.

In my case it was a PHP POST problem. When the devleoper moved thier code to a new Windows box. They ran across a stange problem. They couldn’t make post statements from thier form page into a resulting post page. As it had worked before the natural path was to blame the system and not the code.

The solution turned out to be a mixture of both. In previous default installation the PHP.ini variable register_globals was set to true. In a new PHP installation this is set to false.  While it could be argues that it was a system problem or a coding issue in the end it really doesn’t matter to the client. just as long as it working.

Problem: POST not working in PHP
Solution: Set PHP.ini variable register_globals to true.

SQL profiler and workgroup dilemma

With the Launch of the newest version of SQL 2005 there are several new features of note and some missing components that you should be aware of. Microsoft has developed separate of its editions: express, workgroup, standard, and enterprise. I have noted several clients who choose workgroup as a less expensive alternative to standard edition. In most cases this is quite a suitable choice. After all the workgroup version contains many impressive features such a database size without limitations and the capable of running up to 3GB of RAM. All of these things come with some limitations. Chief among these of the absence of profiler and the database tuning advisor.

As a work around I have found you can run the critical SQL profiler from either a separate workstation or an existing SQL server with standard or enterprise editions. Use this piece of critical software to analyze your queries to fine tune your databases performance. Remember that the key values to note are duration and read times. I’ll write more in depth about these values at a later time.

The database advisor is unfortunately a neat feature that will still be out of your reach with the workgroup edition.

At the very least this will give you a good tool in your arsenal when trying to solve your SQL issues.

SQL stuck in loading after restore

Working in a diverse environment where backup and restores are handled by a different department sometimes small problem can rise into huge monsters if we overlook the details. A recent problem I ran across consisted of restore job where the databases appeared as stuck in loading stage,but not fully functional. After a couple of attempts to restore the database what started as one failed restore turned into three databases all in a loading state. The normal steps of action included dropping the table, but every time I tried the SQL server responded with a message that the database was loading and could not be deleted.

After much research and hitting a couple of brick walls. A next tried to think about this particular problem from a perspective of an isolated database instance without any mitigating factors. I tried a couple of options, which in this case were not successful, but might work under different circumstances.

First, I tried to restore an existing database onto the loading database. This failed again with the error indicating I could perform the action because of loading database.

Next, I spoke to other system administrators and reasoned that in fact the database had been restored with the ‘norecovery’ option. This is by design to put the database into this loading state. It assumes that you will be restoring later transactional file backups on top of the full restore just performed. In fact since we didn’t have those transaction backups this left me rather confused. I again consulted my co-workers and they indicated that I should again try a restore but the the ‘recovery’ option set.

I opened the SQL query manager and ran the following code:

restore database <DATABASE> with recovery

Once I executed this code the database came online and then in turn I could delete the unneeded databases.

Firefox parameter lookups

Hi all. I’m a great fan of Firefox. While I know that Microsoft has tried to replicate many of the features I believe that Firefox has managed to keep one step ahead of them. Among one of the great features is the ability to use parametrized shortcuts. As an simple example let say you perform whois lookups from Network Solutions. Create a bookmark in Firefox with these parmeters:

  • Name:Network Solution Whois lookup
  • Location: http://www.networksolutions.com/whois/results.jsp?domain=%s
  • Keyword: whois

Now when you need to run your next whois on the mozilla.com domain type the following into your toolbar: “whois mozilla.com“. Go ahead try it out if you find yourself repeated returing to a specific website for information and would like to speed up your work flow. The key is the “%s” in your location string. Later on I’ll write about more exotic example but this has helped me a great deal already. There as some example of this on the Internet, try the Mozilla/Firefox Custom Keywords Directory. I hope that this helps you out.

What’s this all about

Truth be told I have never considered myself much of a writer or even much of an extrovert to publish a blog. I started this because as the title has hinted I wanted someway that I can share my knowledge (technical that is) that I acquire as I administrate, design, and generally tinker. Feel free to comment, use, and share.