MySQL basics after installation

Get root password after installation:

cat /var/log/mysqld.log | grep "temporary password"
Connect as root user:
mysql -u root -p{{ password_from_previous_step }}
Change root user password:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPassword4!';
In case you do not want to run above query, run mysql_secure_installation script.

Create additional user:
mysql> CREATE USER 'john'@'localhost' IDENTIFIED BY 'MyNewPass4!';
To create a user for specified host use it's IP address instead of localhost: 192.168.1.10, or use '%' for all hostnames.

After user is added - you must set the permissions what he will have:
mysql> GRANT {{ PERMISSION }} ON {{ db_table }} to 'john'@'localhost';
There are the following permissions:
ALL PRIVILEGES, CREATE, DROP, DELETE, INSERT, SELECT, UPDATE
Example:
mysql> GRANT SELECT, UPDATE ON school.persons to 'john'@'%';
mysql> GRANT SELECT, UPDATE ON school.* to 'john'@'%';
mysql> GRANT ALL PRIVILEGES ON *.* to 'john'@'%';
Show permission grants for an user:
mysql> SHOW GRANTS for 'john'@'localhost';
Show all databases:
mysql> SHOW DATABASES;
Create new database:
mysql> CREATE DATABASE school;
Select or switch to new created database;
mysql> USE school;
Create a new table in selected database:
mysql> CREATE TABLE persons
(
  Name varchar(255),
  Age int,
  Location varchar(255)
);
Show all tables is selected database:
mysql> SHOW TABLES;
Add data to new created table:
mysql> INSERT INTO persons values("John Doe", 45, "New York");
View data from table in selected database:
mysql> SELECT * FROM persons;