application

Setting your MySQL Administrator password and creating Guest Passwords

October 8, 2009

Once MySQL installed & operational, you should immediately set the password for your administrator account (called “root”) and set up at least one guest account, which has limited privileges. Iin the case of the example specified below, the user named “guest” only has SELECT privileges for the database database_name and all tables (specified by the .*) within that database, which works fine for most applications (PHP, etc.) requiring access to a database to pull information out.

  • Open command prompt/command line (Start, Run…, type cmd).
  • Type cd mysql/bin
  • Type mysql –u root mysql to login to the mysql database (contains user table)
  • Type UPDATE user SET Password=PASSWORD(‘new_password’) WHERE user=’root’;
  • Type FLUSH PRIVILEGES; to reset user rights
  • Type exit.
  • Type mysql –u root –p mysql to login to the mysql database (contains user table). You will be    prompted for a the password for the root user.
  • To create guest user account:
    • Type GRANT SELECT ON database_name.* TO guest@’%’ IDENTIFIED BY ‘password’;
    • This will grant SELECT privileges to the user guest when coming from any domain or IP (the ‘%’) using password as the password.
  • Do Step #8 above for every database you want the guest account to have access to.

www.bestitdocuments.com