During this process, enter a strong root password.
sudo apt-get update
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
Check if mysql is running:
systemctl status mysql.service
Should see output like:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2017-12-04 19:33:05 PST; 25s ago
Main PID: 91383 (mysqld)
CGroup: /system.slice/mysql.service
└─91383 /usr/sbin/mysqld
If you don't, try:
sudo systemctl start mysql
Try connecting:
sudo mysql -u root (add -p if need password)
Should see output like:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Create user with password (WARNING: This will grant ALL access):
GRANT ALL PRIVILEGES ON *.* TO '<your_user_name>'@'localhost' IDENTIFIED BY '<your_password>';
\q (to quit)
Test user and create and use database:
sudo mysql -u <your_user_name> -p
CREATE DATABASE <your_database_name>;
USE <your_database_name>;
Posted by hashharvest to Rails CheatSheets (2017-12-04 21:19)