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:
$ sudo mysql_secure_installation
3. Creating MySQL User and Database
3.1. Run MySQL client and enter your MySQL root password
sudo mysql -h localhost -u root -p
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.
CREATE DATABASE hesdb;
CREATE USER 'hesuser'@'%' IDENTIFIED BY '<user_password>';
GRANT ALL ON hesdb.* TO 'hesuser'@'%';
FLUSH PRIVILEGES;
To exit from the MySQL console, press Ctrl+D.
Last updated
Was this helpful?