Advertisement
Guest User

Untitled

a guest
Jan 26th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. DELETE FROM mysql.user WHERE User = '${web_app_sql_user}';
  2.  
  3. #!/bin/bash
  4. echo -e "Creating a SQL user and database for the webapp"
  5.  
  6. read -s -p "enter SQL root user password: " password
  7.  
  8. cat <<- EOF | mysql -v -uroot -p$password
  9. DROP DATABASE IF EXISTS `${web_app_database}`;
  10. CREATE DATABASE `${web_app_database}` CHARACTER SET utf8 COLLATE utf8_general_ci;
  11.  
  12. -- Deal with possibility user already exists!
  13. DELETE FROM mysql.user WHERE User = '${web_app_sql_user}';
  14. -- drop user ${web_app_sql_user}@localhost;
  15. FLUSH PRIVILEGES;
  16.  
  17. CREATE USER '${web_app_sql_user}'@localhost IDENTIFIED BY '${web_app_sql_user_password}';
  18. -- CREATE USER '${web_app_sql_user}'@localhost IDENTIFIED BY '${web_app_sql_user_password}';
  19. GRANT ALL ON ${web_app_database}.* TO '${web_app_sql_user}'@'localhost';
  20.  
  21. GRANT USAGE ON * . * TO '${web_app_sql_user}'@'localhost' IDENTIFIED BY '${web_app_sql_user_password}' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
  22. GRANT ALL PRIVILEGES ON `${web_app_database}` . * TO '${web_app_sql_user}'@'localhost';
  23.  
  24. FLUSH PRIVILEGES;
  25. EOF
  26.  
  27. --------------
  28. DROP DATABASE IF EXISTS `web_app_database`
  29. --------------
  30.  
  31. --------------
  32. CREATE DATABASE `web_app_database` CHARACTER SET utf8 COLLATE utf8_general_ci
  33. --------------
  34.  
  35. --------------
  36. DELETE FROM mysql.user WHERE User = 'web_app_user'
  37. --------------
  38.  
  39. --------------
  40. FLUSH PRIVILEGES
  41. --------------
  42.  
  43. --------------
  44. CREATE USER 'web_app_user'@localhost IDENTIFIED BY ''
  45. --------------
  46.  
  47. ERROR 1396 (HY000) at line 17: Operation CREATE USER failed for 'web_app_user'@'localhost'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement