fixed mysql_database type
can now install a database, and create a user who manages that database
This commit is contained in:
		
					parent
					
						
							
								cfaee39e70
							
						
					
				
			
			
				commit
				
					
						c67c0cf12d
					
				
			
		
					 1 changed files with 12 additions and 5 deletions
				
			
		| 
						 | 
					@ -26,9 +26,11 @@ else # otherwise use the object id as database name
 | 
				
			||||||
   database="$__object_id"
 | 
					   database="$__object_id"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mysql -u root -p <<-EOF
 | 
					cat <<-EOFF
 | 
				
			||||||
 | 
					mysql -u root <<-EOF
 | 
				
			||||||
	CREATE DATABASE IF NOT EXISTS $database
 | 
						CREATE DATABASE IF NOT EXISTS $database
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
 | 
					EOFF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if --user was specified
 | 
					# if --user was specified
 | 
				
			||||||
if [ -f "$__object/parameter/user" ]; then
 | 
					if [ -f "$__object/parameter/user" ]; then
 | 
				
			||||||
| 
						 | 
					@ -37,12 +39,17 @@ if [ -f "$__object/parameter/user" ]; then
 | 
				
			||||||
   # if --password was specified
 | 
					   # if --password was specified
 | 
				
			||||||
   if [ -f "$__object/parameter/password" ]; then
 | 
					   if [ -f "$__object/parameter/password" ]; then
 | 
				
			||||||
      password="$(cat "$__object/parameter/password")"
 | 
					      password="$(cat "$__object/parameter/password")"
 | 
				
			||||||
      mysql -u root -p <<-EOF
 | 
					      cat <<-EOFF
 | 
				
			||||||
 | 
					      mysql -u root <<-EOF
 | 
				
			||||||
      	GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost' IDENTIFIED BY '$password';
 | 
					      	GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost' IDENTIFIED BY '$password';
 | 
				
			||||||
      EOF
 | 
					EOF
 | 
				
			||||||
 | 
					EOFF
 | 
				
			||||||
   else
 | 
					   else
 | 
				
			||||||
      mysql -u root -p <<-EOF
 | 
					      password=""
 | 
				
			||||||
 | 
					      cat <<-EOFF
 | 
				
			||||||
 | 
					      mysql -u root <<-EOF
 | 
				
			||||||
      	GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost';
 | 
					      	GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost';
 | 
				
			||||||
      EOF
 | 
					EOF
 | 
				
			||||||
 | 
					EOFF
 | 
				
			||||||
   fi
 | 
					   fi
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue