iT邦幫忙

0

Day 34 (MySQL)

1.除錯 MySQL02影片00:01


2.MAD利用命令列進入MySQL

$ % = 終端機

(1)以下是 Mac

% cd /Applications/MAMP/Library/bin
% ./mysql -u root -h 127.0.0.1 -P 3306 -p
...
mysql> show databases;
....
mysql> exit
Bye
% 
// 安裝 nmap
% brew install nmap
...
% nmap -v 127.0.0.1

(2)以下是 Windows

搜尋CMD
cd c:\MAMP\bin\mysql\bin
(dir檢查有沒有進去對的地方)
...> mysql -u root -h 127.0.0.1 -P 3306 -p
密碼'root'(昨天設定的)

此時可以執行:(任何在MySQL能做的語法都能做)
(1)mysql> show databases;
(2)mysql> exit; ~~~Bye


3.命令列執行MySQL

(1)mysql> show databases;
(2)mysql> exit;   ~~~Bye
(3)USE northwind(已匯入)
(4)USE northwind(已匯入) > SHOW TABLES;
(5)USE northwind(已匯入) > SELECT 'Hello,World';
(6)USE northwind(已匯入) > SELECT 'Hello,World';
(7)USE northwind(已匯入) > SELECT 10+3;
(8)USE northwind(已匯入) > SELECT 10*3;
(9)USE northwind(已匯入) > SELECT 10/3;
(10)USE northwind(已匯入) > SELECT 10 dIV 3;(整數除)
(11)USE northwind(已匯入) > 
SELECT job_title, first_name, last_name FROM employees

(12)SELECT job_title, first_name, last_name FROM employees ORDER 
BY job_title; 
(排序)

(12)SELECT job_title, first_name, last_name FROM employees ORDER 
BY job_title DESC; 
(排序相反)

SELECT job_title, first_name, last_name FROM employees ORDER 
BY job_title DESC, first_name;
(job_title排序相反 ,first_name排序)

4.語法

(1)新增資料庫

CREATE DATABASE `iii`;

(2)新增表格

CREATE TABLE `iii`.`cust` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `cname` VARCHAR(100) NOT NULL , 
`birthday` DATE NOT NULL , `tel` VARCHAR(100) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;

介面
https://ithelp.ithome.com.tw/upload/images/20210723/201376847XYgFhnYSS.png

(3)新增TABLE內資料

INSERT INTO `cust` (cname,birthday,tel) VALUES('Brad','1999-01-02','0912-123456');

INSERT INTO `cust` (`id`, `cname`, `birthday`, `tel`) VALUES (NULL, 'Peter', '2019-06-04', '0911-222333');

https://ithelp.ithome.com.tw/upload/images/20210723/20137684kny9pdozFt.png

(4)匯入北風資料庫

northwind.sql
northwind-data.sql

北風 資料庫
northwind mysql github
https://github.com/dalers/mywind

https://github.com/dalers/mywind/blob/master/northwind-erd.pdf
https://github.com/dalers/mywind/blob/master/northwind-data.sql
https://github.com/dalers/mywind/blob/master/northwind.sql

a. northwind.sql

DROP SCHEMA(等同DATABASE) IF EXISTS `northwind` ;  如果有其他北風 刪掉
CREATE SCHEMA IF NOT EXISTS `northwind` DEFAULT CHARACTER SET latin1  創一個`northwind`這個資料庫
USE `northwind` ; 使用
CREATE TABLE IF NOT EXISTS `northwind`.`customers`  在`northwind`創表`customers`

b. northwind-data.sql

INSERT INTO `customers` 新增`customers`內部資料

5.掃port看通訊埠有沒有關防火牆

(請掃自己的不要掃人家的,違法)

// nmap => scan port
% nmap -v 127.0.01

6.甚麼git

Git Server => 程式碼伺服器 => 程式版本控制伺服器


尚未有邦友留言

立即登入留言