Install MySQL Server on ubuntu 22.04 and older versions
Install MySQL Server
sudo apt install mysql-server
login in MySQL Server and create users ...
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YOUpassword';
You create a user and database ...
CREATE DATABASE dbname;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'YOUpassword';
GRANT ALL PRIVILEGES ON dbname. * TO 'username'@'localhost';
Additional comments
sudo service mysql status
sudo mysql_secure_installation (on ubuntu 16.04)
mysql -u root -p (login with password)
sudo mysql (frst login one paswword)
Database export:
mysqldump -u root -p dbname > /home/dbofwebsite.sql
If you do not have a database created, you must create it first...
CREATE DATABASE dbwebsite;
To see which databases have been created on the server
SHOW DATABASES;
Importing the database:
mysql -u root -p dbwebsite < /home/dbofwebsite.sql
...