1---2title: 'Mysql Account Creation and Permissions'3date: '2007-05-01'4published_at: '2007-05-01T14:07:00.000+10:00'5tags: ['databases', 'mysql', 'programming']6author: 'Gavin Jackson'7excerpt: 'I finally had a chance to sit down and learn the syntax of creating mysql users and assigning specific permissions. This allows me to have different users for different web services - eg. cron jobs, w...'8updated_at: '2007-05-01T14:27:48.977+10:00'9legacy_url: 'http://www.gavinj.net/2007/04/mysql-account-creation-and-permissions.html'10---1112I finally had a chance to sit down and learn the syntax of creating mysql users and assigning specific permissions. This allows me to have different users for different web services - eg. cron jobs, web servers etc.1314`GRANT [SELECT|UPDATE|INSERT|UPDATE|CREATE|DROP] ON DATABASE.[table`|*] TO 'user'@'host' IDENTIFIED BY 'password'1516These can be cumulative. One thing that originally confused me was the 'host' - you actually need to have two accounts for a user to connect both locally and remotely - one set to "localhost" and the other set to "%".1718The grant command is actually just populating the mysql.user table.1920Other useful commands include changing a password:2122`SET PASSWORD FOR 'bob'@'loclahost" = PASSWORD('newpassword') SET PASSWORD = PASSWORD('newpassword'); GRANT USAGE ON *.* TO 'user`'@'host' IDENTIFIED BY 'password'232425