Wednesday, April 11, 2012

How to do a manual install of MySQL on Windows 7

I've been having great problems with MySQL lately.  It seems no matter what I do it throws up errors when ever I try to install it through the MSI file that it provides. I wont go into details here on the problems that I've been having. Simply put I'd had enough and I did it manually. Here's how I did it.

First download the zip file with the latest copy of MySQL in. You can get it here Remember, if there are two of them, you want the larger one.

Once downloaded you can unzip the files and place them in a folder on your C drive called 'mysql'.

Now, looking online there are several configuration methods available but I found the simplest way was to just create a new text document in the C:\mysql folder and rename it 'my.ini' There's tons of stuff you can put in it but I'll leave that up to you to tweak. For now all you need to put in it is -

[mysqld]
# installation directory
basedir="C:/mysql/"
# data directory
datadir="c:/mysql/data/" 

OK, now we need to test that this has all worked. If you browse to the c:\mysql\bin folder and while holding down shift right click in the folder and choose 'open a command window here'. This will bring up a command prompt. type in -



mysqld

This should start the MySQL service. If the command prompt just hangs there, don't worry about it. Just close the windows and reopen another command prompt in the same location. Now type in


mysql -u root


This will bring up the command line tool for MySQL. One of the most important things you need to do now is change the root password. Type in - 


UPDATE mysql.user SET password=PASSWORD("HereIsWhereUSpecifyANewPassword") WHERE User='root'; 
FLUSH PRIVILEGES;

You will need to make note of this as you will need it to use the command line tool again. Also don't forget the ; at the end of each line.


Still in the command prompt window type


exit;


You should now have a normal prompt again. I think its best to install MySQL as a service. This way you wont have to start it every time. To do this, in the same command prompt type in -


mysqld --install

You should get a response saying it has been successful. Don't forget to change the new MySQL service to automatic in the services menu for it to start automatically.

1 comment:

Jarmez said...

Sorry couldn't help but peruse your blog.

Seeming you're into AutoIT in this situation I am not sure if this would be of any help to you?

http://www.autoitscript.com/forum/topic/50375-msi-editor-a-database/