The documentation of GRANT mentions:
Note
If an account named in a GRANT statement does not already exist, GRANT may create it under the conditions described later in the discussion of the NO_AUTO_CREATE_USER SQL mode. It is also possible to use GRANT to specify nonprivilege account characteristics such as whether it uses secure connections and limits on access to server resources.
However, use of GRANT to create accounts or define nonprivilege characteristics is deprecated as of MySQL 5.7.6. Instead, perform these tasks using CREATE USER or ALTER USER.
The IDENTIFIED by ‘1234’ part of your query is used to set/change the password of the user. The password is not a privilege, it should be changed using ALTER USER.
Use:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'
to grant the desired privileges to the user and:
ALTER USER 'root'@'localhost' IDENTIFIED BY '1234'
to change its password, if needed.
Remark
It is worth mentioning that the ALTER USER statement was introduced in MySQL 5.6. For older versions, the GRANT statement is the only way to change the user's password.