sql >> Database teknologi >  >> RDS >> Mysql

Automatiser mysql_secure_installation med echo-kommando via et shell-script

Jeg faldt over dette spørgsmål, men besluttede at køre forespørgslerne manuelt gennem et Bash-script:

#!/bin/bash

# Make sure that NOBODY can access the server without a password
mysql -e "UPDATE mysql.user SET Password = PASSWORD('CHANGEME') WHERE User = 'root'"
# Kill the anonymous users
mysql -e "DROP USER ''@'localhost'"
# Because our hostname varies we'll use some Bash magic here.
mysql -e "DROP USER ''@'$(hostname)'"
# Kill off the demo database
mysql -e "DROP DATABASE test"
# Make our changes take effect
mysql -e "FLUSH PRIVILEGES"
# Any subsequent tries to run queries this way will get access denied because lack of usr/pwd param


  1. skråstreg før hvert citatproblem

  2. Perl DBI indsæt flere rækker ved hjælp af mysql native multiple insert-evne

  3. Sådan udføres lagret procedure i MySQL Workbench

  4. LazyInitializationException forsøger at få doven initialiseret instans