MySQL

by v10.1.44 | Debian 9

World’s most popular open source database.

Configure and deploy a relational database management system used by enterprises and small businesses alike. MySQL, or MariaDB for Linux distributions, is primarily used for web and server applications, including as a component of the industry-standard LAMP and LEMP stack. MySQL is a popular choice for high-growth environments and the developers who maintain them due to its reliability, out-of-the-box security, and flexibility in order to scale.

Launch MySQL with Linode’s One-Click to start building your own database.

MySQL/MariaDB Options

FIELDDESCRIPTION
MySQL UserThe user for your MySQLDB database. Required.
MySQL Root PasswordThe root password for your MySQL database. Required.
Create DatabaseThe database on your MySQL. Required.

Getting Started After Deployment

Access MySQL/MariaDB

  1. SSH into your Linode and create a limited user account.
  2. Log out and log back in as your limited user account.
  3. Update your server:
    sudo apt-get update && apt-get upgrade

Using MySQL/MariaDB

The standard tool for interacting with MySQL is the mysql client which installs with the mysql-server package. The MySQL client is used through a terminal.

Root Login

  1. To log in to MySQL as the root user:
    sudo mysql -u root -p
  2. When prompted, enter the MySQL root password that you set when launching the One-Click App. You’ll then be presented with a welcome header and the MySQL prompt as shown below:
    MariaDB [(none)]>
  3. To generate a list of commands for the MySQL prompt, enter \h. You’ll then see:
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear command.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don't write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.

For server side help, type 'help contents'

MariaDB [(none)]>

4. Grant access to the database that you created when launching the One-Click App for MySQL User. In this example, the database is called webdata, the user webuser, and password of the user is password. Be sure to enter your own password. This should be different from the root password for MySQL:

GRANT ALL ON webdata.* TO 'webuser' IDENTIFIED BY 'password';

5. To Exit MySQL/MariaDB type:

exit

Create a Sample Table

  1. Log back in as MySQL User that you set when launching the One-Click App. In the following example the MySQL User is webuser

    sudo mysql -u webuser -p
  2. Create a sample table called customers. This creates a table with a customer ID field of the type INT for integer (auto-incremented for new records, used as the primary key), as well as two fields for storing the customer’s name. In the following example webdata is the database that you created when launching the One-Click App.
    use webdata;
    create table customers (customer_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name TEXT, last_name TEXT);

3. To view the contents of the table that you created:describe customers; The output would be:

Table Content Reference Image

4. Then exit MySQL/MariaDB.
exit

This One-Click App was built by Linode. For support regarding app deployment, contact Linode Support via the information listed in the sidebar. For support regarding the tool or software itself, visit MySQL Support.