MySQL / MariaDB
Install MySQL or MariaDB
Ubuntu
sudo apt install -y mysql-server
sudo mysql_secure_installation
About installation
- Choose password level, I advice
LOW
to avoid problems with password. - Define password
- Select
Yes
for all questions after this.
Connect to MySQL CLI
Ubuntu
sudo mysql -u root -p
Redefine validate_password.policy
if necessary and root
password if necessary
mysql
SET GLOBAL validate_password.policy=LOW;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'super_secret_password';
FLUSH PRIVILEGES;
It's not a good idea to have one user to manage all databases,
root
user is useful to create database and users but only with MySQL CLI and not with phpMyAdmin because phpMyAdmin have online access. It's a good idea to create ONE user BY database and give rights about this database only to this NEW user (androot
of course). And, the most important, in your application, give new user for credentials. With this solution, your credentials can only manage ONE database, it's more secure if someone find credentials.
Here, it's an example of this solution, my_project_database
and my_project_user
can be same.
mysql
CREATE DATABASE my_project_database;
CREATE USER 'my_project_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'secret_password';
GRANT ALL ON my_project_database.* TO 'my_project_user'@'localhost';
Give all rights to one user, except root but root will be disable for phpMyAdmin.
CREATE USER 'my_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'my_user'@'localhost' WITH GRANT OPTION;
exit