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 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











Go 언어는 효율적이고 간결하며 배우기 쉬운 프로그래밍 언어입니다. 동시 프로그래밍과 네트워크 프로그래밍의 장점 때문에 개발자들이 선호합니다. 실제 개발에서 데이터베이스 작업은 필수적인 부분입니다. 이 기사에서는 Go 언어를 사용하여 데이터베이스 추가, 삭제, 수정 및 쿼리 작업을 구현하는 방법을 소개합니다. Go 언어에서는 일반적으로 사용되는 SQL 패키지, Gorm 등과 같은 타사 라이브러리를 사용하여 데이터베이스를 운영합니다. 여기서는 sql 패키지를 예로 들어 데이터베이스의 추가, 삭제, 수정 및 쿼리 작업을 구현하는 방법을 소개합니다. MySQL 데이터베이스를 사용하고 있다고 가정합니다.

Apple의 최신 iOS18, iPadOS18 및 macOS Sequoia 시스템 릴리스에는 사진 애플리케이션에 중요한 기능이 추가되었습니다. 이 기능은 사용자가 다양한 이유로 손실되거나 손상된 사진과 비디오를 쉽게 복구할 수 있도록 설계되었습니다. 새로운 기능에는 사진 앱의 도구 섹션에 '복구됨'이라는 앨범이 도입되었습니다. 이 앨범은 사용자가 기기에 사진 라이브러리에 포함되지 않은 사진이나 비디오를 가지고 있을 때 자동으로 나타납니다. "복구된" 앨범의 출현은 데이터베이스 손상으로 인해 손실된 사진과 비디오, 사진 라이브러리에 올바르게 저장되지 않은 카메라 응용 프로그램 또는 사진 라이브러리를 관리하는 타사 응용 프로그램에 대한 솔루션을 제공합니다. 사용자는 몇 가지 간단한 단계만 거치면 됩니다.

Hibernate 다형성 매핑은 상속된 클래스를 데이터베이스에 매핑할 수 있으며 다음 매핑 유형을 제공합니다. Join-subclass: 상위 클래스의 모든 열을 포함하여 하위 클래스에 대한 별도의 테이블을 생성합니다. 클래스별 테이블: 하위 클래스별 열만 포함하는 하위 클래스에 대한 별도의 테이블을 만듭니다. Union-subclass: Joined-subclass와 유사하지만 상위 클래스 테이블이 모든 하위 클래스 열을 통합합니다.

HTML은 데이터베이스를 직접 읽을 수 없지만 JavaScript 및 AJAX를 통해 읽을 수 있습니다. 단계에는 데이터베이스 연결 설정, 쿼리 보내기, 응답 처리 및 페이지 업데이트가 포함됩니다. 이 기사에서는 JavaScript, AJAX 및 PHP를 사용하여 MySQL 데이터베이스에서 데이터를 읽는 실제 예제를 제공하고 쿼리 결과를 HTML 페이지에 동적으로 표시하는 방법을 보여줍니다. 이 예제에서는 XMLHttpRequest를 사용하여 데이터베이스 연결을 설정하고 쿼리를 보내고 응답을 처리함으로써 페이지 요소에 데이터를 채우고 데이터베이스를 읽는 HTML 기능을 실현합니다.

MySQLi를 사용하여 PHP에서 데이터베이스 연결을 설정하는 방법: MySQLi 확장 포함(require_once) 연결 함수 생성(functionconnect_to_db) 연결 함수 호출($conn=connect_to_db()) 쿼리 실행($result=$conn->query()) 닫기 연결( $conn->close())

PHP에서 데이터베이스 연결 오류를 처리하려면 다음 단계를 사용할 수 있습니다. mysqli_connect_errno()를 사용하여 오류 코드를 얻습니다. 오류 메시지를 얻으려면 mysqli_connect_error()를 사용하십시오. 이러한 오류 메시지를 캡처하고 기록하면 데이터베이스 연결 문제를 쉽게 식별하고 해결할 수 있어 애플리케이션이 원활하게 실행될 수 있습니다.

PHP는 웹사이트 개발에 널리 사용되는 백엔드 프로그래밍 언어로, 강력한 데이터베이스 운영 기능을 갖추고 있으며 MySQL과 같은 데이터베이스와 상호 작용하는 데 자주 사용됩니다. 그러나 한자 인코딩의 복잡성으로 인해 데이터베이스에서 잘못된 한자를 처리할 때 문제가 자주 발생합니다. 이 기사에서는 잘못된 문자의 일반적인 원인, 솔루션 및 특정 코드 예제를 포함하여 데이터베이스에서 중국어 잘못된 문자를 처리하기 위한 PHP의 기술과 사례를 소개합니다. 문자가 왜곡되는 일반적인 이유는 잘못된 데이터베이스 문자 집합 설정 때문입니다. 데이터베이스를 생성할 때 utf8 또는 u와 같은 올바른 문자 집합을 선택해야 합니다.

Golang의 데이터베이스 콜백 기능을 사용하면 다음을 달성할 수 있습니다. 지정된 데이터베이스 작업이 완료된 후 사용자 정의 코드를 실행합니다. 추가 코드를 작성하지 않고도 별도의 함수를 통해 사용자 정의 동작을 추가할 수 있습니다. 삽입, 업데이트, 삭제, 쿼리 작업에 콜백 함수를 사용할 수 있습니다. 콜백 함수를 사용하려면 sql.Exec, sql.QueryRow, sql.Query 함수를 사용해야 합니다.
