Creating and Updating MySQL Accounts / hosts.allow

Posted by: scoopseven 12 years, 7 months ago

Here's a quick script for creating or updating MySQL accounts via the command line so that you're able to login from any host. It's really easy to replace the '%' with your actual hostname or ip to make this more secure, so if at all possible, you should.

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost';
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%';

To update:

use mysql;
update user set password=PASSWORD("password") where User='username';

Also remember, if you're on a linux box and you're trying to connect from a remote host, you have to edit hosts.allow and add mysql.  Otherwise mysql will throw a "ERROR 2013 can't connect to 127.0.0.1" error.

mysqld: ALL: ALLOW

Again, that's insecure, just add your particular host to make sure you're not allowing connections to mysql anywhere

Currently unrated


Recent Tweets

Recent Posts

Archive

2013
2012
2011
2010
2009
2008
2007
2006

Categories

Authors

Feeds

RSS / Atom