charlieanstey
2/13/2015 - 6:10 PM

MySQL :: Common commands

#MySQL common commands


# Create database
CREATE DATABASE name;

# Show databases
SHOW DATABASES;

# Use database
USE database;

---

# Create user
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';

# Allow user access to entire database
GRANT ALL PRIVILEGES ON base.* TO 'user'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, DELETE ON base.* TO 'user'@'localhost' IDENTIFIED BY 'password';

# Remove user access to database
REVOKE ALL PRIVILEGES ON base.* FROM 'user'@'host'; -- one permission only
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'host'; -- all permissions

# Remove password for root on localhost
SET PASSWORD FOR root@localhost=PASSWORD('');

---

UPDATE table SET column=`some value` WHERE something=true;

---

DELETE FROM table WHERE something='this';