MySQL Installation Problem: Can’t create pid file – no such file or directory

Problem: can’t create pid file: no such file or directory

I had this problem and had a very tough and frustrating time with it. While I was installing a fresh copy of MySQL 5 in Windows XP, I got this problem. (I was installing it from the installer i.e. setup file.) The server was not starting and ‘error 0’ was displayed. I tried to start the server from the command line by typing “mysqld-nt –console” and then got the error “can’t create pid file: no such file or directory“. It was also displaying the message like “cannot create/write file C:\Program Files\MySQL\MySQL Server 5.0\data\com2.pid”.

Solution:

The main problem was my computer name. My computer name was ‘com2‘. MySQL makes the file with the computer name in the directory of it’s data (in my case C:\Program Files\MySQL\MySQL Server 5.0\data\) . Now, it was unable to create a file named com2 (which was my computer name) because in WINDOWS you cannot make file/folder with the name com1,com2,com3… and so on.

Hence, I changed my computer name, restarted my computer and then reconfigured MySQL. All well done and MySQL started running.