How to install and create a database in Ubuntu 20.04?
1.Log in terminal
2. If new server. Update and install MySQL server.
- apt update
- apt install mysql-server
3.Log into MySQL without a password.
- mysql
4. Create a database
Example: Create a ‘School’ database
mysql> create database School;
5. Create tables in the database.
Example: Create a Student_details table in the School database.
mysql> create table Students_Detalis (student_id int, student_name varchar(50), student_marks int, student_mobile_no int);
6. Check tables in the School database whether they table create or not.
How to take backup and restore the MySQL database?
[edit]Go to the MySQL directory and have the databases directories
#cd /var/lib/mysql
Dumb the School database to School_information.sql file.
#mysqldump -u root School > School_information.sql
Log into the mysql and check the databases.
mysql> show databases;
Go to the School database and Check the tables.
mysql > show tables;
Delete the School database.
mysql> drop database School;
Create a database to restore the deleted database.
mysql> create database School_information;
Exit, Go to mysql directory and restore the dumping file.
#cd /var/lib/mysql
- mysql -u root -p School_information < School_information.sql
Check the restore table in School_information.





