Only tested and working commands are here. Used in
Ubuntu 24.04 LTS
The key for single quotes is --> ' <-- it is mandatory. It's located on the keyboard to the left of the number key1. For some reason, some article editors tend to replace it with a custom type of quote. If this happens, type it again instead of copying it.
In the already installed SQL
To delete a user
DROP USER 'username'@'localhost';
To view existing users (useful to see if the user was actually deleted)
SELECT user FROM mysql.user;
To view existing users and their hosts
SELECT user, host FROM mysql.user;Tocreate a user
CREATE USER 'silvio_uphpmy'@'localhost' IDENTIFIED BY 'passwordhere';
To check a user's permissions
SHOW GRANTS FOR 'username'@'localhost';
If you want to grant all privileges to a user on the database, use the following code:
GRANT ALL PRIVILEGES ON mydatabase.* TO 'username'@'localhost';
To grant permissions for all databases, it is
GRANT ALL PRIVILEGES ON *. * TO ‘username’@’localhost’;
I used localhost because it's the default. Only advanced users should use something different, as they will naturally have to edit the hosts.
To view existing databases.
SHOW DATABASES;
.



