開發者必備 Linux MySQL 基礎操作:安裝、啟動、登入、資料庫/表建立與切換。
$ sudo apt-get install -y mysql-server
$ mysql -V
$ sudo service mysql start # stop/restart 同理
$ mysql -u root -p
mysql> SHOW DATABASES;
mysql> CREATE DATABASE newone;
mysql> USE newone;
mysql> SHOW TABLES;
mysql> CREATE TABLE person (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(20), age INT);
mysql> DROP TABLE person;
; 結尾,Linux 命令不需。-p 後或換行隱式輸入(更安全)。information_schema、performance_schema、mysql 勿刪。