Installing MySQL for Ubuntu
From the Ubuntu desktop:
- Go to System > Administration > Synapatic Package Manager
- Search for “mysql-server” and “Mark for installation”
- Click on the “Apply” to install
From the command line:
$ sudo apt-get install mysql-server
Setting a Password for the MySQL Root User
By default the MySQL installation doesn’t have the password set for root. To set the password at the unix prompt:
$ mysqladmin -u root password <password>
Creating a Database in MySQL
Login into MySQL as root and in the prompt type:
mysql> CREATE DATABASE <database name>
Granting Privileges in MySQL
In the MySQL prompt:
mysql> GRANT <what to grant> ON <database name>.* TO '<username>'@'<hostname>' IDENTIFIED BY '<password>'
Backing Up Your Database
Use the mysqldump command line:
$ mysqldump <database name>
To backup more than one database:
$ mysqldump --databases <database 1> <database 2>
To backup all the databases:
$ mysqldump --all-databases
Restoring Your Database
$ mysql -u <username> -p <database name> < <database backup file>
Related posts: