Structured Query Language (SQL) Database
code
Basic command line operations and syntax in linux (debian-based)
- Open MySQL command line interface
The -u
parameter defines the user (in this case root
) while the blank -p
triggers user input for the associated password. Below is a a primer for common SQL operations.
Note: SQL commands are terminated by a semi-colon character ;
SQL table operations
- Create a table with defined columns
- Note that various data types can be defined for each column. These are oulined in the official MySQL reference documentation.
- Delete a table from current database
- Select a database for table operations
- List all tables in current database
- List all entries in a table
SQL user privilege assignment and user modification operations
- Grant all privileges for
databaseuser
ondatabase
- Always reload privileges;
Advanced features
More advanced operations and SQL server settings are outlined below.
Enable remote client access
This allows database access from outside of the localhost environment.
- Enable standard firewall port used for SQL
- Enable port in SQL configuration file and disable binding SQL server to localhost
[mysqld]
port=3306
skip-networking=0
skip-bind-address
- Login to the mysql shell as
root
and define a new user with remote access privileges from a remote ip (or range)
Note the %
is a wildcard
character. It must be enclosed by quotes.