Skip to content

Instantly share code, notes, and snippets.

@envygeeks
Last active February 12, 2019 19:30
Show Gist options
  • Save envygeeks/789971fd9b25375ab504ee27066b75c3 to your computer and use it in GitHub Desktop.
Save envygeeks/789971fd9b25375ab504ee27066b75c3 to your computer and use it in GitHub Desktop.
Force own MySQL Root
SET @@SESSION.SQL_LOG_BIN=0;
DELETE FROM mysql.user WHERE Host = '';
DELETE FROM mysql.user WHERE User = 'root';
DELETE FROM mysql.user WHERE User = '$MYSQL_USER';
CREATE OR REPLACE USER 'root'@'%' IDENTIFIED BY '$MYSQL_ROOT_PASS';
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;
DROP DATABASE IF EXISTS test;
CREATE DATABASE IF NOT EXISTS $MYSQL_DB;
CREATE OR REPLACE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASS';
GRANT ALL ON $MYSQL_DB.* TO '$MYSQL_USER'@'%';
FLUSH PRIVILEGES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment