DELETE FROM mysql.user WHERE user NOT IN ('mysql.sys', 'mysqlxsys', 'root') OR host NOT IN ('localhost'); GRANT ALL ON *.* TO root@localhost WITH GRANT OPTION; DROP DATABASE IF EXISTS test; CREATE DATABASE IF NOT EXISTS $DB_NAME CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL ON $DB_NAME.* TO '$DB_USER'@localhost IDENTIFIED BY '$DB_PASSWD';