MySQL on Linux

1. Install

CentOS Stream 9:

sudo dnf install mysql-server -y

Enable and start MySQL service:

sudo systemctl restart mysqld.service
sudo systemctl enable mysqld.service

Ubuntu

$ sudo apt install mysql-server -y

2. Change the authentication parameters:

sudo mysql 

run command in mysql console:


ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '<mysql_root_password>';

Сhange <mysql_root_password> to a strong password,

To exit from the MySQL console, press Ctrl+D.

  • run mysql_secure_installation, to complete the installation:

3. Creating MySQL User and Database

3.1. Run MySQL client and enter your MySQL root password

3.2. The following lines create a database hesdb, the user with name hesuser and password <user_password>. Сhange <user_password> to a strong password, otherwise you may get a password validator error.

To exit from the MySQL console, press Ctrl+D.

Last updated