# LINUX-- ubuntu 16 共用方法1掛CD 2共用 3windows共用
###### tags: `learn`
USE 練習庫 INSERT INTO [練習庫].[dbo].[ 客戶](客編,名稱,信用額度)
VALUES('C06','宏碁資訊','95000'), ('C07','聯強資訊','85000'), ('C08','大同資訊','90000')
USE 練習庫 INSERT [dbo].[資一乙] ([學號],[NAME],[MALE],[國文],[英文]) SELECT [學號], [NAME],[SEX] AS [MALE],[國文],[英文] FROM [dbo].[資一甲] WHERE [SEX]='男'
USE 練習庫 SELECT * INTO #主管薪資表 FROM [dbo].[華中資訊] WHERE [薪資]>60000 GO SELECT * FROM #主管薪資表 GO
USE 練習庫 UPDATE [dbo].[華中資訊] SET [薪資]=[薪資]+2000 OUTPUT DELETED.員工編號 ,DELETED.姓名 ,DELETED.薪資 ApS 加薪前,INSERTED.薪資 AS 加薪後 WHERE [部門]='資訊部'
[1](https://drive.google.com/drive/u/1/folders/1c_zoY_ySGDuV3E25f4lX_vo6ksja5-Go)
## 4月底
#### 0.
安裝失敗時刪除~
sudo rm -R /var/lib/apt/lists/lock
1.安裝插件
sudo apt-get install libaio1 libaio-dev
2.解壓縮 loaaaaaaadiiiiiing
sudo tar -vxzf mariadb-10.1.38-linux-glibc_214-x86_64.tar.gz
3.add群組
sudo groupadd mysql
4.add user
sudo useradd -r -g mysql -s /bin/false mysql
5.移動(cd download)
sudo mv mariadb-10.1.38-linux-x86_64 /usr/local/mysql
mariadb-10.1.38-linux-x86_64
位置::
cd /usr/local/mysql
[change owner | group]
sudo chown -R mysql .
sudo chgrp -R mysql .
[連結link-s]sudo rm /etc/my.cnf
sudo ln -s /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
6.建立安裝的資料夾,權限設定
sudo mkdir /MySQLData
sudo chmod 777 -R /MySQLData
[create a customer profile ||mysql -u root -p ]
sudo gedit /etc/profile.d/customer.sh
//add
export PATH=/usr/local/mysql/bin:$PATH
!!!save
####
------------------------------------
## 7.安裝
sudo scripts/mysql_install_db --user=mysql --datadir=/MySQLData
8.[change]
sudo chown -R root .
sudo chown -R mysql MySQLData
9.[more]
sudo gedit /etc/my.cnf
////////////////////////////add below line at mysqld
datadir =/MySQLData
10.啟用
sudo bin/mysqld_safe --user=mysql&
sudo ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
sudo /etc/init.d/mysql start
11.[create a customer profile ||mysql -u root -p ]
sudo gedit /etc/profile.d/customer.sh
//add
export PATH=/usr/local/mysql/bin:$PATH
!!!save
12.enable
# sudo systemctl enable mysql
# sudo systemctl is-enabled mysql
### testing
/* login mysql */
mysql -u root -p
MariaDB [(none)]> show databases ;
/* exit mysql */
exit
/* change mysql root password */
mysqladmin -u root password 'yourpassword'
show database
show tables
use mysql ;
create database sam >>dir
[ login mysql ]
mysql -u root -p
MariaDB [(none)]> show databases ;
/* exit mysql */
exit
/* change mysql root password */
mysqladmin -u root password 'yourpassword'
## 5/1
### 清除single server
列出
# ps -ef |grep mysql
停用
sudo systemctl disable mysql
停用
sudo /etc/init.d/mysql stop
刪除啟動檔 init.d
sudo rm -f /etc/init.d/mysql
刪除
sudo rm -f /etc/my.cnf
cd /MySQLData
清空
# sudo rm -fr *
ls看一下
//清除
### multi 3個server cd
to MySQLData
#### 1
sudo mkdir MySQL1
sudo mkdir MySQL2
sudo mkdir MySQL3
更改權限
sudo chown mysql:root *
sudo chmod 777 -R *
進入/usr/local/mysql
cd /usr/local/mysql
安裝x3
sudo scripts/mysql_install_db --user=mysql --datadir=/MySQLData/MySQL1
sudo scripts/mysql_install_db --user=mysql --datadir=/MySQLData/MySQL2
sudo scripts/mysql_install_db --user=mysql --datadir=/MySQLData/MySQL3
### 建立multi sever
to suport-file
cd support-files
複製cnf
sudo cp my-medium.cnf my-multi.cnf
sudo chown root:mysql my-multi.cnf
調整權限
sudo chgrp mysql *
更改cnf要參考 網址
https://dev.mysql.com/doc/refman/8.0/en/mysqld-multi.html
gedit
sudo gedit /usr/local/mysql/support-files/my-multi.cnf
網址複製貼上
手動安裝路竟沒錯==local ;如果是自動安裝位置會跑掉
碼掉
[mysql]
#
#
#在[mysqld] 後面加入 multi server 環境設定如下
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = multi_admin
password = my_password
[mysqld1]
socket = /tmp/mysql.sock1
port = 3306
pid-file = /MySQLData/MySQL1/mysql1.pid
datadir = /MySQLData/MySQL1
[mysqld2]
socket = /tmp/mysql.sock2
port = 3307
pid-file = /MySQLData/MySQL2/mysql2.pid
datadir = /MySQLData/MySQL2
[mysqld3]
socket = /tmp/mysql.sock3
port = 3308
pid-file = /MySQLData/MySQL3/mysql3.pid
datadir = /MySQLData/MySQL3
---
== ll /etc/my.cnf
ll /etc/init.d/mysql==
sudo rm -f /etc/my.cnf
#產生/etc/my.cnf 連結
sudo ln -s /usr/local/mysql/support-files/my-multi.cnf /etc/my.cnf
---
ps -ef |grep mysql
sudo rm -f /etc/my.cnf
cd /usr/local/mysql
#建立my_print_defaults 程式連結
sudo ln -s /usr/local/mysql/bin/my_print_defaults /usr/bin/.
#啟動safe 模式,目錄一
sudo bin/mysqld_safe --user=mysql --datadir=/MySQLData/MySQL1 &
#啟動safe 模式,目錄二
sudo bin/mysqld_safe --user=mysql --datadir=/MySQLData/MySQL2 &
#啟動safe 模式,目錄三
sudo bin/mysqld_safe --user=mysql --datadir=/MySQLData/MySQL3 &
建立起動的程式
#建立務啟動程式程式連結
sudo ln -s /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/mysql
#啟動mysql
sudo /etc/init.d/mysql start
---
### 複製貼上
cd /usr/local/mysql/support-files
sudo gedit mysql.server
# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $local_fs $network $remote_fs
# Should-Start: ypbind nscd ldap ntpd xntpd
# Required-Stop: $local_fs $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop MariaDB
# Description: MariaDB is a very fast and reliable SQL database engine.
### END INIT INFO
/etc/init.d/mysql version>
---
#變更資料庫一密碼
mysqladmin -u root password '1' -h 127.0.0.1 -P 3306
#變更資料庫二密碼
mysqladmin -u root password '2' -h 127.0.0.1 -P 3307
#變更資料庫三密碼
mysqladmin -u root password '3' -h 127.0.0.1 -P 3308
mysql -u root -p 127.0.0.1 -P 3307
mysql -u root -p
## mid1
sudo rm -R /var/lib/apt/lists/lock
sudo apt-get install openssl libssl-dev
>>y
extract zip
### __to your dir >>download right termi. 2.2.24
sudo ./configure --prefix=/usr/local/ZZZ --enable-so --enable-headers --enable-expires --enable-rewrite --enable-ssl
~~sudo ./configure --prefix=/opt/apache2 --enable-so --enable-headers --enable-expires --enable-rewrite --enable-ssl ~~
:+1:
sudo make
sudo make install
[sudo rm /etc/init.d/httpd]
sudo ln -s /usr/local/ZZZ/bin/apachectl /etc/init.d/httpd
~~sudo ln -s /opt/apache2/bin/apachectl /etc/init.d/httpd~~
:+1:
# sudo /etc/init.d/httpd start
sudo mkdir /var/html
:+2:
sudo chmod 777 -R /var/html
:+2: /*變更資料夾用戶讀寫權限 */
new index.html++
<html>
<body>
Hello this is from new area
</body>
</html>
sudo gedit /opt/apache2/conf/httpd.conf
:+1:
啟動 gedit 後
找到 Listen 80
改成 Listen 808 /*將 http 連接 port 變更成 808 */
存檔後重新啟動 apache 嘗試連結 http://localhost:808
sudo gedit /usr/local/ZZZ/conf/httpd.conf
:+1:
1
找到 DocumentRoot "/usr/local/apache/htdocs"
改成 DocumentRoot "/html" /*變更網頁根目錄 , 到指定 /**www** 資料夾 */
找到 <Directory "/usr/local/apache/htdocs">
改成 <Directory "/html"> /*變更網頁根目錄 , 到指定 /**www** 資料夾 */
存檔後重新啟動 apache 嘗試連結 http://localhost:808
[sudo /etc/init.d/httpd start]
sudo systemctl enable httpd /*設定 httpd 服務於開機時自動啟動 */
sudo systemctl is-enabled httpd
## 2/27
期中考: ubuntu OS,Appache,php,防火牆
sudo ln -s /usr/local
1. 喜好設定
2. [virtualbox]
3. 在資訊欄光碟處 上ISO
4. 語言 打勾打勾 erase,LVM 英文語系 密碼 [顯示部OK靠tab]
5. 只移除不刪除 靠新增
6. 使用資料夾複製 匯入
7. 共享功能掛載
8. sudo gedit /edit/group
9. 顯示(4:3)
other:
GCP(google cloud platform)
區塊鍊 hash 暴力破解(易算難解)
IoT
AI
## 3/06
other:
服務&應用程式
UI圖形介面 開機背景執行 multithread同時n人執行
### SOP
sudo password / unzip y/n
download -> 下載
unzip -> 解壓縮
address -> 找到解壓縮位置
configure-> 組態(簡單來說就是我們windows10安裝程式時,打勾的步驟)
make -> 編譯
make install -> 安裝
start -> 啟動
---
### CODE [cd .. Tab/]
//sudo gcc
sudo apt-get install gcc
cd Download*
cd http*
---
sudo apt-get install openssl libssl-dev [安裝SSL擴充包]

./configure --prefix=/usr/local/apache --enable-so --enable-headers --enable-expires --enable-rewrite --enable-ssl --disable-env --disable-userdir [組態]

sudo make [編譯]
sudo make install [安裝]
cd /usr/local/apache/bin [到檔案位置]
sudo ./apachectl start [啟動]
<? (other) loclhost sudo ./apachectl stop ?>

conf ->設定
到htdos ->編輯127.0.0.1
sudo gedit index.html
| owner | group | others |
| -------- | -------- | -------- |
| r w x | _ _ _ | _ _ _ |
| 讀 寫 執行 | Text | Text |
| 111 | 101 | 101
drwxr -xr -x [7 5 5] d是資料夾

---
file address
computer/usr/local/apache
rm remove
-----------------
[sudo rm /etc/init.d/httpd]
### 1.link 開機啟用init
sudo ln -s /usr/local/apache/bin/apachectl /etc/init.d/httpd[移動link]
sudo /etc/init.d/httpd start
測試1
ps -ef | grep httpd
[host ssl密碼 在extra設定]<?
### 變更document dir
win10 不要放在c槽 放D
?>
sudo mkdir /www
ll /usr/local/apache
2.打開檔案 之後編輯
sudo gedit /usr/local/apache/conf/httpd.conf
改port__[ Listen 80 ]
[# DocumentRoot]
文字編輯器:
sudo gedit /usr/local/apache/conf/httpd.conf
[/www]
3.創建html
sudo gedit /www/index.html
<html><body> 123 </body></html>
sudo /etc/init.d/httpd stop
sudo /etc/init.d/httpd start
完成>> 關掉重開 之後要重新整理
4.改掉LISTEN : 80
88
檔案刪掉怎麼辦? copy別人的>>644
rwrr 644 不能執行
要改成rwxr 755
sudo chmod 755 -R 檔案/目錄
sudo chmod 755 -R /www
rwx rwx 766 755都可 但是我們可以做777
(owner group others)底下都直接套用[R大寫]
---
找到document root
sudo gedit /usr/local/apache/conf/httpd.conf
1 "/www"
2 
## 4/3
開機自動啟用



指令:工作管理員
pf -ef
指令:工作管理員_停用服務[PID =4260]
kill -9 4260
進度:
最高權限 系統control 狀態 [檔案name]
sudo systemctl status httpd
啟用
sudo systemctl enable httpd
確認是否啟用
sudo systemctl is-enabled httpd
httpd.conf 重要文件
sudo gedit /etc/init.d/httpd
下載 marriaDB 10.1版本 linux
https://downloads.mariadb.org/mariadb/10.1.38/#os_group=linux_generic
```
#### BEGIN INIT INFO
# Provides: httpd
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Apache
# Description: Apache
### END INIT INFO#
```
---
sudo gedit /etc/init.d/httpd
在 #!/bin/sh 下加入這段內容
```
#### BEGIN INIT INFO
# Provides: httpd
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Apache
# Description: Apache
### END INIT INFO#
```