Skip to content

Instantly share code, notes, and snippets.

@superjojo140
Last active September 9, 2020 09:53
Show Gist options
  • Save superjojo140/063ed8f131083769588975f607a8f174 to your computer and use it in GitHub Desktop.
Save superjojo140/063ed8f131083769588975f607a8f174 to your computer and use it in GitHub Desktop.
Mysql Cheatsheet

Use mysql CLI

mysql --user=my_username --password

Create a new user

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

Create new database and grant privilleges

CREATE DATABASE `db_name`;
GRANT ALL PRIVILEGES ON `db_name` . * TO 'username'@'localhost';

Reset password

SET password for 'username'@'localhost' = password('my_new_password');

Start mysql server without password request

Stop mysqld process

sudo mysqld_safe --skip-grant-tables &

Connect to mysql server from your root systemuser via socket (no password required)

sudo mysql --protocol=socket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment