Connection and basic operations
# Connection syntax
mysql -u <user> -p
# Show databases
show databases;
# Use database
use <databasename>;
# Show tables
show tables;
# Disconnect
exit;
Create user
# New drivers syntax
CREATE USER 'newuser'@'localhost' IDENTIFIED BY '<password>';
# Old drivers syntax
CREATE USER 'newuser'@'localhost' IDENTIFIED WITH mysql_native_password BY '<password>';
Grant privileges
# Grant all privileges
GRANT ALL PRIVILEGES ON * . * TO '<user>';
Execute script from file
source <file_path>
0 Comments