MySQL UUID() behavior 4 years ago, I answered a question on SO, &quot;how to set an UUID for each row in bulk&quot;.
I answered, after trying it,
UPDATE table SET uuidcol = UUID();

It worked for me, but about half (it seems) people report that it doesn't work, saying the ID is identical on all rows.
So today, I tried again, dropping each time the column, and creating a new one with a new type, like
text, char(36), varchar(36)

and it worked again, making a unique UUID per row, each time.
What could make that it does not work for other people?
The engine for instance? ( using InnoDB on MySQL 5.7 )
edit
Did another test by

creating a simple table t of a uu varchar(36)
inserting 10,000,000 lines with uu being null
did the UPDATE t SET uu=UUID();

and all of the 10M lines have a different, unique UUID.
I'm having this exact same problem right now.
I have written a sample java Application to demonstrate the problem:
MariaDBTestUUID.java:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MariaDBTestUUID
{
    private Connection connect;
    private Statement statement;
    private ResultSet resultSet;

    public void updateUUID() throws Exception
    {
        try
        {
            // This will load the MySQL driver, each DB has its own driver
            Class.forName(&quot;org.mariadb.jdbc.Driver&quot;);
            // Setup the connection with the DB
            connect = DriverManager
                    // AWS Aurora (MySQL server 5.6.10) - found with SQL &quot;show variables like '%version%';&quot;
                    .getConnection(&quot;jdbc:mariadb://&lt;hostname&gt;:3306/&lt;DB name&gt;?user=&lt;user&gt;&amp;password=&lt;password&gt;&quot;);
//                     // local MySQL server (5.7.22)
//                    .getConnection(&quot;jdbc:mariadb://localhost:3306/licenceserver4?user=root&amp;password=&lt;password&gt;&quot;);
//                     // docker container MySQL server (5.7.30)
//                    .getConnection(&quot;jdbc:mariadb://localhost:3307/testDB?user=root&amp;password=&lt;password&gt;&quot;);

            // PreparedStatements can use variables and are more efficient
            PreparedStatement preparedStatement =
                connect.prepareStatement(&quot;UPDATE testUUID SET new_id = uuid(), new_id2 = REPLACE(uuid(), '-', ''), new_id3 = UNHEX(REPLACE(uuid(), '-', ''))&quot;);
            preparedStatement.executeUpdate();

            queryStrings(&quot;select ID, new_ID, new_ID2, hex(new_ID3) as new_ID3 from testUUID&quot;);
            queryStrings(&quot;select count(distinct(new_ID)) as distinct_rows from testUUID&quot;);
            queryStrings(&quot;select count(distinct(new_ID2)) as distinct_rows2 from testUUID&quot;);
            queryStrings(&quot;select count(distinct(new_ID3)) as distinct_rows3 from testUUID&quot;);
        }
        catch (Exception e)
        {
            throw e;
        }
        finally
        {
            close();
        }
    }

    private void queryStrings(String sql) throws SQLException
    {
        System.out.println(&quot;Running \&quot;&quot; + sql + &quot;\&quot;... &quot;);
        statement = connect.createStatement();
        // Result set get the result of the SQL query
        resultSet = statement
            .executeQuery(sql);
        writeResultSet(resultSet);
    }

    private void writeResultSet(ResultSet resultSet) throws SQLException
    {
        // ResultSet is initially before the first data set
        while (resultSet.next())
        {
            // we can only do this because we know they are all strings
            for (int i = 1; i &lt;= resultSet.getMetaData().getColumnCount(); i++)
            {
                String value = resultSet.getString(i);
                System.out.print(resultSet.getMetaData().getColumnName(i) + &quot;: &quot; + value + &quot;, &quot;);
            }
            System.out.println();
        }
    }

    // You need to close the resultSet
    private void close()
    {
        try
        {
            if (resultSet != null)
            {
                resultSet.close();
            }

            if (statement != null)
            {
                statement.close();
            }

            if (connect != null)
            {
                connect.close();
            }
        }
        catch (Exception e)
        {
            System.out.println(&quot;Error closing:&quot;);
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws Exception
    {
        new MariaDBTestUUID().updateUUID();
    }
}

The version of the client library is set here:
build.gradle:
plugins {
    id 'java'
}

sourceCompatibility = 11

repositories {
    mavenCentral()
}

dependencies {
    // DB driver
    runtimeOnly 'org.mariadb.jdbc:mariadb-java-client:2.2.4'
}

To run the test application, just:
1 - connect to each of the DBs and run the following queries:
create table testUUID (ID int, new_ID varchar(100), new_ID2 varchar(100), new_ID3 BINARY(16));
insert into testUUID (id) values (1),(2),(3);

2 - replace the connection info masked for security reasons and run it on each of the DBs.
3 - set the version of mariadb client to use in the test in build.gradle
4 - run main()
If the output shows 3 for each of the distinct queries, the update stmt created distinct values in each column.
If it shows 1, the update set the same value to all rows for that column.
The queries should all return 3.
What I saw, for all DBs:

With mariadb client 2.2.3, it returns 3 for all queries.
With mariadb client 2.2.4, it returns 1 for the second and third queries (new_ID2 and new_ID3).

So, my findings so far:

Everything worked without issues (all columns in every row were set with distinct values) until version 2.2.3 of the mariadb client library.
From version 2.2.4, it started setting identical values on every row for columns we were setting to replace(uuid(),'-', '') using a single update statement.
This happens with several further mariadb client versions as well, including the latest (2.7.0).

Either the issue is related to the REPLACE() function, or to the nesting of function calls in the update. It is definitely not caused by the function UUID().

The issue happens equally in MySQL 5.7.22 (locally installed in my env), MySQL 5.7.30 (test docker container), and more importantly, Aurora DB (MySQL 5.6.10).


----------------------------------------------------
EDIT
----------------------------------------------------
For me, this was caused by a conjunction of:

the database charset
a change in MariaDB J/Connector starting at version 2.2.4
the combination of UUID() and String processing functions (like REPLACE())

Adding CONVERT() to the picture solved it:
UPDATE sometable SET uuid=UNHEX(REPLACE(CONVERT(UUID() using utf8mb4), '-', '')) WHERE uuid IS NULL;
For more details (and an upvote): https://stackoverflow.com/a/51393124/5154619