Debian: Install and set up MySQL - how it works
To use a web server under Debian Linux you need MySQL. Find out in this practical tip how to install and set it up on Debian.
Install and set up MySQL on Debian - so it'll work
- Log in to Debian as administrator and open the terminal.
- With "sudo apt-get install mysql-server" MySQL is downloaded and the installation started. Simply follow the instructions.
- When the installation is complete, you have to assign a password. Use "mysqladmin -u root -p password" PASSWORD "" and change "PASSWORD" with a desired password.
- Now you can log in to MySQL using "mysql -u root -p" and entering the previously defined password.
- With the command "create database if not exists database name;" create a new database with the name "database name", which you can adapt as you like.
- This database now gets another user with the password "secret".
- create user 'www-data' @ 'localhost' identified by 'secret';
- grant usage on *. * to 'www-data' @ 'localhost' identified by 'secret';
Next steps: Install and set up MySQL
- Enter the following command so that the user also has the appropriate access:
- grant all privileges on database name. * to 'www-data' @ 'localhost';
- flush privileges;
- Exit the configuration with "quit" or "exit". Then use "sudo systemctl restart mysql.service" to restart the MySQL server and apply the changes.
- With the command "create database if not exists database name;" create a new database with the name "database name", which you can adapt as you like.
- This database now gets another user with the password "secret".
- create user 'www-data' @ 'localhost' identified by 'secret';
- grant usage on *. * to 'www-data' @ 'localhost' identified by 'secret';
If you would also like to set up an FTP server under Linux Debian, we will show you how in the next practical tip.