# 新機台安裝資料庫系統並嘗試匯出資料 # apt-get install mariadb-server # lsblk # mount /dev/sdb1 /mnt/rescue # /etc/init.d/mariadb stop # mv /var/lib/mysql /var/lib/_mysql # cp -R /mnt/rescue/var/lib/mysql /var/lib/ -R # chown -R mysql:mysql mysql # /etc/init.d/mariadb start # # 匯出資料庫檔案 # mysqldump -u db_user -p --default-character-set=utf8 mydb > mydb_backup.sql
百憂解
3月 11, 2025
Google Cloud 災難復原
12月 26, 2024
Java 透過 Oracle Wallet 連線資料庫
2. 編譯方式
D:\jdk17\bin\javac.exe -cp .;D:\ojdbc17-full\ojdbc17.jar OraDBConn.java D:\jdk17\bin\java.exe -cp .;D:\ojdbc17-full\ojdbc17.jar OraDBConn3. 範例程式碼 (OraDBConn.java)
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.ResultSet; import java.sql.Statement; public class OraDBConn { public static void main(String[] args) { // Database connection information String host = "10.18.1.1"; String port = "1522"; String serviceName = "SNAME"; String db_user_id = "TESTID"; String db_user_pwd = "2wsx3edc"; String jdbcUrl = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=" + "(PROTOCOL=TCPS)(HOST=" + host + ")(PORT=" + port + ")))" + "(CONNECT_DATA=(SERVICE_NAME=" + serviceName + ")))"; // Need [cwallet.sso] file for SSO authentication System.setProperty("oracle.net.wallet_location", "D:\\wallet"); try { // Establish a connection using the Oracle Wallet Connection connection = DriverManager.getConnection(jdbcUrl, db_user_id, db_user_pwd); System.out.println("Connection established successfully!"); Statement stmt = connection.createStatement(); String sqlcode = "SELECT * FROM OWNER.Table13 WHERE ROWNUM <= 3"; ResultSet rs = stmt.executeQuery(sqlcode); while(rs.next()) System.out.println(rs.getString(5) + "\t"); connection.close(); } catch (SQLException e) { e.printStackTrace(); System.out.println("Failed connect."); } } }
12月 02, 2024
開源遠端桌面閘道(Apache Guacamole)
Apache Guacamole
A clientless remote desktop gateway. It supports standard protocols like VNC, RDP, and SSH. We call it clientless because no plugins or client software are required. Guacamole is installed on a server, all you need to access your desktops is a web browser.遠端桌面閘道(RD Gateway)支援 RDP 及 SSH 協定;使用者透過瀏覽器可直接存取遠端桌面,無需設定。
11月 26, 2024
9月 18, 2024
自建 Uptime Kuma 監測平台
# apt-get -y update # apt-get install -y nodejs npm git # npm install pm2 -g # pm2 install pm2-logrotate安裝 Uptime Kuma
# git clone https://github.com/louislam/uptime-kuma.git # cd uptime-kuma # npm run setup # pm2 start server/server.js --name uptime-kuma進行初次設定 http://localhost:3001
8月 28, 2024
moto g34 5G 手機
小時候認識的摩托羅拉是 Motorola, Inc.,而現在 (2014 起) 則為聯想集團的全資子公司 Motorola Mobility LLC。雖不若以往強盛,但偶有佳作。
moto g34 5G 規格
- 處理器 Snapdragon® 695 5G
- 作業系統 Android™ 14
- 儲存空間 64GB、記憶體 4GB
- 螢幕 6.5 吋、重量 179g、電池 5000mAh
- 具備 NFC、側邊指紋辨識器、3.5mm 耳機孔
聯想並沒投注太多心力在風格打造,手機介面幾乎就是原生安卓 (Stock Android),這點意味能夠體驗精簡設計,用戶依自身需求安裝軟體。相較於 Pixel 手機而言,除了相機平庸之外,其餘 (CPU 與售價) 皆完美。
7月 13, 2024
Cookies Having Independent Partitioned State (CHIPS)
Cookie 分區儲存,第三方 Cookie 只允許讀取同網域下的內容,無法跨站存取。
Cookies Having Independent Partitioned State (CHIPS) allows developers to opt a cookie into partitioned storage, with separate cookie jars per top-level site, improving user privacy and security.
Without partitioning, third-party cookies can enable services to track users and join their information from across many unrelated top-level sites. This is known as cross-site tracking.
停用方式:
[Chrome]
在 chrome://flags/ 中更改設定 Third-party Storage Partitioning = Disable
[Firefox]
在 about:config 中更改設定 network.cookie.cookieBehavior 改成 4
愈來愈嚴格!
4月 29, 2024
在 GitHub Codespaces 中運行 CodeIgniter v4.5
因為 CodeIgniter v4.5 需要 PHP 8.1 及 PHP-intl 元件才能運作,原生 GitHub Codespaces 運作 Ubuntu 20.04 LTS 版本,快速解法是直接透過 Personal Package Archives(PPA) 補齊新版套件,並把環境鏈結刪除(current),最後再用 composer 把 CodeIgniter 裝起來。
[啟用第三方套件庫] # add-apt-repository ppa:ondrej/php # apt install php8.3-{cli,intl,curl,mbstring,mysql,sqlite3,gd} phpunit [確定當前PHP呼叫路徑] # which php # 可能是 /home/codespace/.php/current/bin/php # 或者是 /usr/local/php/current/bin/php [重新建立鏈結(current),最新版位於 /usr/bin/php8.3] # rm /home/codespace/.php/current # rm /usr/local/php/current # ln -s /usr /home/codespace/.php/current # ln -s /usr /usr/local/php/current # 執行 php --ini 或 php -m 驗證環境 [安裝資料庫] # apt install mariadb-server # /etc/init.d/mysql start # mysql_secure_installation
4月 15, 2024
Redmi Note 13 Pro 5G
Redmi Note 13 Pro 5G ($8,990)
- 處理器:Qualcomm Snapdragon 7s Gen 2
- SIM卡:5G + 5G
- 螢幕:6.67 吋
- 重量:187g
- 螢幕指紋辨識、支援 NFC、3.5mm 耳機孔
1月 04, 2024
常用 git 指令與自建 Gitea Server
- git 個人設定值存放於 C:\Users\account\.gitconfig
- ssh 個人公私錀存放於 C:\Users\account\.ssh\
git config --global user.name "Foo Bar" git config --global user.email foo@bar.com git config --global --list git config --global --list --show-origin
2. 使用 SSH 應當是較為安全的管道,在原始碼上傳前,需預先部署公鑰在遠端伺服器(GitHub或Gitea),本地端推送(PULL)時則出示私鑰進行授權。所以記得使用 ssh-keygen 產生公私鑰放在家目錄 [.ssh] 資料夾。
[HTTPS]
git init git checkout -b main // 建立並切換到 main 分支 git add . // 加入檔案到 staging git commit -m "first commit" // 加到本地 repository git remote add origin https://example.com/user/foo.git // git remote add [remote-name] [remote-url] git push -u origin main // 推送本地分支(main)到遠端位址(origin)[SSH]
git init git checkout -b main git add README.md git commit -m "first commit" git remote add origin git@github.com:user/foo.git // 透過 SSH 上傳需佈建公鑰(id_rsa.pub)在遠端 git push -u origin main[其他常用指令]
git log // 列出提交歷史 git status // 列出狀態 git remote -v // 列出遠端位址 git remote set-url origin// 更改遠端倉庫位址對應