This appendix will give you a short summary of useful MySQL commands that can be executed at the command line on the system that is hosting the MySQL database.
Some useful commands are given in the following table. It should be noted that this is not a comprehensive list of commands.
Description of the command |
Command to be run on Raspbmc |
---|---|
Connects to MySQL with the user as |
mysql -u root -ppassword
Remember, there must be a space after |
Creates a user with a specific password |
CREATE USER ‘sam’@’localhost’ IDENTIFIED BY ‘password’;
|
Creates a database |
CREATE DATABASE somedb;
|
Grants a user full privileges to access all databases |
GRANT ALL PRIVILEGES ON *.* TO ‘sam’@’%’;
|
Grants a user full privileges to access a specific database |
GRANT ALL PRIVILEGES ON somedb.* TO ‘sam@localhost’;
|
Deletes a MySQL database |
DROP DATABASE dbname;
|
Makes a backup of a database |
mysqldump -u root -ppassword somedb > backup.sql
|
Restores a backup of a database |
mysql –u root -ppassword somedb < backup.sql
|
Note that somedb
, sam
, and dbname
, used in preceding table, are just examples and should be substituted accordingly to match your configuration.
More information about MySQL commands can be obtained from http://dev.mysql.com/doc/refman/5.0/en/mysql-commands.html.