Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The following procedure prevents mysql passwords from showing up in your mysql or bash history.
- ### Create random password
- // create random password with openssl
- $ openssl rand -base64 32 | head -c 16
- wZw0USspr+eTKFNQ
- // create random password with python (more complex)
- $ python -c "import string;from random import choice; print ''.join([choice(string.ascii_letters + string.digits + string.punctuation) for i in range(16)])"
- lD#':_7vxZZW7Sm!
- ### Create mysql pw hash from password
- $ python -c 'from hashlib import sha1; import getpass; print "*" + sha1(sha1(getpass.getpass("New MySQL Password:")).digest()).hexdigest()'
- New MySQL Password:<password input doesn't show>
- *64e48b3407dd769ba941a67fce1480f3caab35c8
- ### Use hash in mysql
- // add user
- mysql> create user 'username'@'server.lan' identified by password '*64e48b3407dd769ba941a67fce1480f3caab35c8';
- // change user pw
- mysql> update mysql.user set authentication_string='*64e48b3407dd769ba941a67fce1480f3caab35c8' where user="username";
Add Comment
Please, Sign In to add comment