Skip to content

Instantly share code, notes, and snippets.

@micheledurante
Last active May 15, 2017 21:22
Show Gist options
  • Save micheledurante/bf3a2b05538f1221e4f2c6d04392287a to your computer and use it in GitHub Desktop.
Save micheledurante/bf3a2b05538f1221e4f2c6d04392287a to your computer and use it in GitHub Desktop.
SQL code
  • New user CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'test123test!';

  • Remove user DROP USER 'phpmyadmin'@'localhost';

  • Grant rights GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'%' WITH GRANT OPTION;

  • Revoke rights REVOKE ALL PRIVILEGES ON phpmyadmin.* FROM 'phpmyadmin'@'localhost';

  • Import from backup SOURCE backup_file.sql;

  • Change password of root user

  1. sudo /etc/init.d/mysql stop
  2. sudo mysqld_safe --skip-grant-tables --skip-networking &
  3. mysql -u root mysql
  4. use mysql;
  5. update user set password=PASSWORD("NEWPASSWORD") where User='root';
  • Password ENCRYPT('firstpassword', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment