MySQL::Sandbox
MySQL::Sandbox这东西用起来还真简单hellip;hellip;可以快速地安装一个或者一组mysql服务端程序。安装的时候使用root用户,只需
MySQL::Sandbox
这东西用起来还真简单……可以快速地安装一个或者一组mysql服务端程序。
安装的时候使用root用户,只需要一条命令就搞定:
# cpan MySQL::Sandbox
日常使用的时候,就不需要root权限了。
以用户modify为例:
1) 建立一个存放mysql源程序的仓库,并设置环境变量。 [modify@H209 ~]$ mkdir /home/modify/mysql =/home/modify/mysql 2) 下载mysql5.6.10的安装文件 (mysql-5.6.10-linux-glibc2.5-i686.tar.gz) 281.7M 到/home/modify/mysql目录中。 [modify@H209 ~]$ ls /home/modify/mysql mysql-5.6.10-linux-glibc2.5-i686.tar.gz 3) 创建第一个sandbox: 第一次需要解压,所以时间会长一些 [modify@H209 ~]$ make_sandbox /home/modify/mysql/mysql-5.6.10-linux-glibc2.5-i686.tar.gz unpacking /home/modify/mysql/mysql-5.6.10-linux-glibc2.5-i686.tar.gz Executing low_level_make_sandbox --basedir=/home/modify/mysql/5.6.10 \ --sandbox_directory=msb_5_6_10 \ --install_version=5.6 \ --sandbox_port=5610 \ --no_ver_after_name \ --my_clause=log-error=msandbox.err >>/tmp The MySQL Sandbox, version 3.0.30 (C) 2006-2013 Giuseppe Maxia installing with the following parameters: upper_directory = /home/modify/sandboxes sandbox_directory = msb_5_6_10 sandbox_port = 5610 check_port = no_check_port = datadir_from = script install_version = 5.6 basedir = /home/modify/mysql/5.6.10 tmpdir = my_file = operating_system_user = modify db_user = msandbox remote_access = 127.% ro_user = msandbox_ro rw_user = msandbox_rw repl_user = rsandbox db_password = msandbox repl_password = rsandbox my_clause = log-error=msandbox.err master = slaveof = high_performance = prompt_prefix = mysql prompt_body = \d) > force = no_ver_after_name = 1 verbose = load_grants = 1 no_load_grants = no_run = no_show = do you agree? ([Y],n) 安装之后的文件存在于 /home/modify/sandboxes/msb_5_6_10 目录中。而且已经启动了mysqld. [modify@H209 ~]$ ls /home/modify/sandboxes/ clear_all msb_5_6_10 plugin.conf restart_all sandbox_action send_kill_all start_all status_all stop_all use_all 4)连接到sandbox: [root@H209 modify]# /home/modify/sandboxes/msb_5_6_10/use Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.6.10 MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql nonemysql noneuser(); +--------------------+ +--------------------+ | msandbox@localhost | +--------------------+ sec再创建一个5.6.10的sandbox: 在第一次创建之后,源程序仓库中已经有了一个名为5.6.10的目录,其实就是从mysql-5.6.10-linux-glibc2.5-i686.tar.gz中解压出来的: [modify@H209 ~]$ ls /home/modify/mysql 5.6.10 mysql-5.6.10-linux-glibc2.5-i686.tar.gz 此时再创建5.6.10的sandbox,就比较简单了: [modify@H209 ~]$ make_sandbox 5.6.10 ...... upper_directory = /home/modify/sandboxes sandbox_directory = msb_5_6_10 sandbox_port = 5610 check_port = no_check_port = datadir_from = script ...... ...... do you agree? ([Y],n) y 然后提示: /home/modify/sandboxes/msb_5_6_10 already exists. 不止这个目录会冲突,mysqld使用的端口也会冲突,于是还要加一个参数: [modify@H209 ~]$ make_sandbox 5.6.10 -- --check_port ...... upper_directory = /home/modify/sandboxes sandbox_directory = msb_5_6_10_a sandbox_port = 5611 ..... 安装目录变成了 msb_5_6_10_a, 端口也加了1,变为5611,相当智能。 [modify@H209 ~]$ ls /home/modify/sandboxes/msb_5_6_10_a/ change_paths clear grants.mysql msb my.sandbox.cnf rescue_mysql_dump.sql send_kill status tmp USING change_ports data load_grants my proxy_start restart start stop use 此目录中的start, stop, restart用于启动,,关闭,重启mysqld。 6) sbtool 此命令可以copy ,move, change port,delete某个sandbox。 详情看文档。 7) make_replication_sandbox 可以创建一主二从(当然这个结构也是可以用参数来调整的)。 [modify@H209 ~]$ make_replication_sandbox 5.6.10 installing and starting master installing slave 1 installing slave 2 starting slave 1 ... sandbox server started starting slave 2 ... sandbox server started initializing slave 1 initializing slave 2 replication directory installed sandboxes/rsandbox_5_6_10 [modify@H209 ~]$ ls /home/modify/sandboxes/rsandbox_5_6_10/ check_slaves clear_all enable_gtid initialize_slaves m master node1 node2 restart_all s1 s2 send_kill_all start_all status_all stop_all use_all 此目录中的m相当于use master, s1相当于use slave 1, s2相当于 use slave 2。 [modify@H209 ~]$ /home/modify/sandboxes/rsandbox_5_6_10/s2 Warning: /home/modify/.mylogin.cnf should be readable/writable only by current user. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.6.10-log MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. slave2 noneshow slave status \G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 127.0.0.1 Master_User: rsandbox Master_Port: 18675 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 2590 Relay_Log_File: mysql_sandbox18677-relay-bin.000002 Relay_Log_Pos: 2753 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 2590 Relay_Log_Space: 2939 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 Master_UUID: c52c239c-78d6-11e2-917f-00241db92e69 Master_Info_File: /home/modify/sandboxes/rsandbox_5_6_10/node2/data/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: sec) slave2 none没有使用到最新的Auto_Position与GTID,有点遗憾。
熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

熱門話題

Go語言是一種高效、簡潔且易於學習的程式語言,因其在並發程式設計和網路程式設計方面的優勢而備受開發者青睞。在實際開發中,資料庫操作是不可或缺的一部分,本文將介紹如何使用Go語言實作資料庫的增刪改查操作。在Go語言中,我們通常會使用第三方函式庫來操作資料庫,例如常用的sql套件、gorm等。這裡以sql包為例介紹如何實作資料庫的增刪改查操作。假設我們使用的是MySQL資料庫。

Hibernate多態映射可映射繼承類別到資料庫,提供以下映射類型:joined-subclass:為子類別建立單獨表,包含父類別所有欄位。 table-per-class:為子類別建立單獨資料表,僅包含子類別特有列。 union-subclass:類似joined-subclass,但父類別表聯合所有子類別列。

蘋果公司最新發布的iOS18、iPadOS18以及macOSSequoia系統為Photos應用程式增添了一項重要功能,旨在幫助用戶輕鬆恢復因各種原因遺失或損壞的照片和影片。這項新功能在Photos應用的"工具"部分引入了一個名為"已恢復"的相冊,當用戶設備中存在未納入其照片庫的圖片或影片時,該相冊將自動顯示。 "已恢復"相簿的出現為因資料庫損壞、相機應用未正確保存至照片庫或第三方應用管理照片庫時照片和視頻丟失提供了解決方案。使用者只需簡單幾步

HTML無法直接讀取資料庫,但可以透過JavaScript和AJAX實作。其步驟包括建立資料庫連線、發送查詢、處理回應和更新頁面。本文提供了利用JavaScript、AJAX和PHP來從MySQL資料庫讀取資料的實戰範例,展示如何在HTML頁面中動態顯示查詢結果。此範例使用XMLHttpRequest建立資料庫連接,發送查詢並處理回應,從而將資料填入頁面元素中,實現了HTML讀取資料庫的功能。

PHP處理資料庫連線報錯,可以使用下列步驟:使用mysqli_connect_errno()取得錯誤代碼。使用mysqli_connect_error()取得錯誤訊息。透過擷取並記錄這些錯誤訊息,可以輕鬆識別並解決資料庫連接問題,確保應用程式的順暢運作。

如何在PHP中使用MySQLi建立資料庫連線:包含MySQLi擴充(require_once)建立連線函數(functionconnect_to_db)呼叫連線函數($conn=connect_to_db())執行查詢($result=$conn->query())關閉連線( $conn->close())

PHP是一種廣泛應用於網站開發的後端程式語言,它具有強大的資料庫操作功能,常用於與MySQL等資料庫進行互動。然而,由於中文字元編碼的複雜性,在處理資料庫中文亂碼時常常會出現問題。本文將介紹PHP處理資料庫中文亂碼的技巧與實踐,包括常見的亂碼原因、解決方法和具體的程式碼範例。常見的亂碼原因資料庫字元集設定不正確:資料庫建立時需選擇正確的字元集,如utf8或u

在Golang中使用資料庫回呼函數可以實現:在指定資料庫操作完成後執行自訂程式碼。透過單獨的函數新增自訂行為,無需編寫額外程式碼。回調函數可用於插入、更新、刪除和查詢操作。必須使用sql.Exec、sql.QueryRow或sql.Query函數才能使用回呼函數。
