To log in to your MySQL server, you need to have the credentials of a user with sufficient privileges. Open the terminal or command prompt and enter the following command:
mysql -u {username} -p
Replace {username} with the username of the user with the necessary privileges.
You will be prompted to enter the password for the user. Once you successfully log in, you will see the MySQL shell prompt:
mysql>
To create a new database, use the following command:
CREATE DATABASE {database_name};
Replace {database_name} with the name you want to give to your new database.
To create a new user, use the following command:
CREATE USER '{username}'@'localhost' IDENTIFIED BY '{password}';
Replace {username} with the username you want to give to your new user and {password} with the password you want to set for the user.
Next, you need to grant the necessary privileges to the user. Use the following command:
GRANT ALL PRIVILEGES ON {database_name}.* TO '{username}'@'localhost';
Replace {database_name} and {username} with the respective names you used earlier.
After executing these commands successfully, you can exit the MySQL shell by typing:
exit;