mysql5: username,password,database = domain

Often in development, I want to throw up a custom mysql db just to dump junk for a project in.

Typically this is a small scale, 0 security scenario just to dump some crap into.

I like to have the database name, username and password all be the same.

Here is a little script to mysql5 user create / user add it up:

export domain="fnck"
export UP="-uroot -proot"
mysqladmin ${UP} create ${domain}
cat << EOM | mysql ${UP}
CREATE USER '${domain}'@'localhost' IDENTIFIED BY '${domain}';
GRANT ALL PRIVILEGES ON ${domain}.* TO '${domain}'@'%' WITH GRANT OPTION;
EOM
echo "show tables;" | mysql -u${domain} -p${domain} ${domain}

I rolled it up into nu_mysql_duh_buh.sh

5uck it!

For some reason, ports install of mysql 5 on my mac has a fckng “5” on the end of all the commands:

cd /opt/local/bin
for dumb in mysq*5 ; do 
   duh=$( echo ${dumb} | sed 's,5$,,' ) 
   sudo ln -s ${dumb} ${duh} 
done
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: