MariaDB (MySQL)
技術筆記
安裝
sudo apt install mariadb-server
sudo mysql # 第一次進入
使用者
- change password find here
SET PASSWORD = PASSWORD('new_password');
- 新增使用者 find here
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'*' IDENTIFIED BY 'password';
GRANT command PRIVILEGES ON db.table TO 'username'@'localhost' IDENTIFIED BY 'password';
- 刪除使用者 find here
DROP USER IF EXISTS user
操作
Create New DB
CREATE DATABASE testDB;
Drop DB / table / column / row
DROP DATABASE "db_name"; # DB
DROP TABLE "table_name"; -- table
ALTER TABLE "table_name" DROP "column_name"; /* column */
DELETE FROM "table_name" WHERE condition;
Use .sql file
mysql -p < xxx.sql
Dump DB in / out
- in
mysqlimport --ignore-lines=1 --fields-terminated-by=, --verbose --local -u [user] -p [database] /path/to/address.csv
- out