Issue with creating mysql user in AWS

When I create a user in mysql manually, like

CREATE USER 'user'@'%' IDENTIFIED BY 'password';
GRANT ALL ON database.* TO 'user'@'%';
FLUSH PRIVILEGES;

My user can conenct to the database from the remote server

When i do the same from flyway however, my user cannot connect.

Just wondering if there is something stupid I am missing here? 

Flyway versions tried were 7.15.0 and 10.10.0 and mysql in AWS version 5.7.


Tagged:

Answers

  • Hi @Zagurim
     
    Thank you reaching out on the Redgate forums regarding your Flyway / MySQL query.
     
    When you say you are doing the same in Flyway, can you confirm how you are doing it - via a migration to create the user?
     
    I would be expecting a process similar to this, depending on if you are setting up other users/objects etc

     

    Create a Flyway migration file
    When creating scripts, it’s crucial these scripts are idempotent and error-free. E.G.:
     
    -- Filename: V1__Create_user.sql<br>CREATE USER IF NOT EXISTS 'user'@'%' IDENTIFIED BY 'password';<br>GRANT ALL ON database.* TO 'user'@'%';<br>FLUSH PRIVILEGES;
    • File Naming: Make sure your migration files are named in a way that Flyway recognizes and runs them in the correct order (e.g., V1__Create_user.sql, V2__Next_change.sql).

     

    Run the migration in Flyway

    When running Flyway migrate, pay attention to the logs for any errors or warnings that could indicate what went wrong:
     
    flyway migrate

     

    Check MySQL User Connection

    After running your migrations, test the connection as the newly created user:
     
    mysql -u user -p -h <host> -D database
    • Error Messages: Any errors here can give clues—whether it’s a password issue, permissions problem, or something else.

     

    Possibly AWS Specific Settings

    You mention using AWS - some areas to check here include:
    • Network Access: Ensure the security group and network ACLs allow connections from your desired location.
    • Parameter Group: Sometimes, settings in the RDS parameter group can affect connection behaviour (e.g., requiring SSL).

     

    Alternate testing - Testing Connection Locally

    Try to mimic the Flyway operations manually via a script or the MySQL command line, exactly as Flyway would execute them:
     
    mysql -u admin_user -p -h <host> -e "SOURCE path_to_your_migration_script.sql"
     
    This would be the starting point to try and flush out where any issues/errors may be occurring in your configuration. 
    Any messages at these points should help start to find where the process is falling down for you
    Jon Kirkwood | Technical Support Engineer | Redgate Software

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file