9 August 2011

Notes on setting up mySql to work with dSurvey

Step 0: If you have just installed WAMP, the first thing to do is to change 
your mysql "root" password. Here is one way to do it.

  a) Open up a command prompt
  b) Find the MYSQL directory. For example, if you installed Wamp to C:\WAMP,
     it might be C:\wamp\bin\mysql\mysql5.5.8\bin
  c) Run mysql using
         C:\wamp\bin\mysql\mysql5.5.8\bin>mysql -uroot -p
  d) When asked to Enter a password, hit Enter (the installation default
     is no password).
     You will see a welcome message that begins with something like
          Welcome to the MySQL monitor.
     and at the end a prompt that looks like
          mysql>
  e)Enter
        mysql> use mysql;
     (don't forget the trailing semi-colon)
     You should a see message like:
	Database changed
   f)Enter
        mysql> update user set password=password(‘yourPassword’)
               where host=’localhost’;
      (you can enter this on one line)
      (change the yourPassword to your preferred password)
      You should see a message like:
	Query OK, 1 row affected (0.00 sec)
   g) Enter
       mysql> flush privileges;
   h) You can then exit, using
       mysql> \q


      To make sure it worked, rerun mysql using:
          C:\wamp\bin\mysql\mysql5.5.8\bin>mysql -uroot -pyourPassword
      (of course, the yourPassword should be the password used in step f above)
      This should take you to the mysql> prompt.

   i) In order for the phpMyAdmin option of Wamp to work, you need to change the
      phpMyAdmin configuration file
	i) Find the phpMyAdmin directory. For example:
	     C:\wamp\apps\phpmyadmin3.3.9
        ii) Edit the config.inc.php in this directory
	iii) Change the
	     $cfg['Servers'][$i]['password'] = ''  ;
           to
	     $cfg['Servers'][$i]['password'] = 'yourPassword'
           (the yourPassword should be the pasword set in step f above)
        iv) Save.

       To make sure this worked, click on the phpMyAdmin choice under the
       Wamp menu -- the phpMyAdmin screen shoud appear.

       If you get some kind of error message, some people report 
       that they need to change
          $cfg['Servers'][$i]['AllowNoPassword'] = false ;
       or, perhaps add
          $cfg['Servers'][$i]['AllowNoPasswordRoot'] = false ;


Step 1: To create a dsurveyAdmin username for mysql

dSurvey assumes that a dsurveyAdmin username exists in mysql. That means you
MUST create this username in mySql.

You can create this using the following steps:

1) From a command prompt in the mysql directory
   mysql --user=root mysql  -pmypassword

   Say, if mysql is installed in D:\MYSQL, and if your root password 
  (say, created in step 0) is keving, then you would use:
         C:\wamp\bin\mysql\mysql5.5.8\bin>mysql -uroot -pkeving

2) Create a dsurveyAdmin user with the appopriate privileges
   mysql> CREATE USER 'dsurveyAdmin'@'localhost' IDENTIFIED BY 'admin';
   mysql> GRANT ALL PRIVILEGES ON *.* TO 'dsurveyAdmin'@'localhost'
       ->     WITH GRANT OPTION;

3) Verify it worked:
      mysql> SHOW GRANTS FOR 'dsurveyAdmin'@'localhost';
   which should return something like:
      | GRANT ALL PRIVILEGES ON *.* TO 'dsurveyAdmin'@'localhost' IDENTIFIED
        BY PASSWO  RD '*4ACFE3202A5FF5CF467898FC58AAB1D615029441' WITH
        GRANT OPTION |
  (the about would appear on one long line)
