W: H: YOffset??

MySQL / MariaDB install, configure, quick commands

How to install MySQL version 8.0 and further configuration steps on a debian server.

Quick install on debian

 

sudo apt update
sudo apt install mysql-server

# During the installation process, you will be prompted to set a root password for MySQL.
# Secure the MySQL installation by running:
sudo mysql_secure_installation

# Install PHP and necessary extensions by running the following command:
sudo apt install php php-mysql

# Restart the Apache web server to apply the changes:
sudo systemctl restart apache2

 

Database & user short cuts

 


# Log into MySQL as root:
mysql -u root
# Create a new database user:
GRANT ALL PRIVILEGES ON *.* TO 'db_user'@'localhost' IDENTIFIED BY 'P@s$w0rd123!';
# or just grant access to a database without password
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
# saving the data
FLUSH PRIVILEGES;
# Log out of MySQL by typing: \q.
# Log in as the new database user you just created:
mysql -u db_user -p
#create new database
CREATE DATABASE db_name;
#show the users databases
SHOW DATABASES;