把A中的q1倒出來 mysqldump -uadmin1 -padmin111 Q1 Q1.sql

10年的民豐網(wǎng)站建設經(jīng)驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設備顯示端的尺寸不同,自動調整民豐建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)公司從事“民豐網(wǎng)站設計”,“民豐網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。
然后再B中新建Q2,create database Q2
應用Q2 use Q2
導入Q1 source Q1.sql
賦予用戶 grant all privileges on Q2.* to 'admin2'@localhost identified by 'admin2222'
這樣就可以了!
這篇文章主要介紹了php實現(xiàn)redis數(shù)據(jù)庫指定庫號遷移的方法,涉及對于redis數(shù)據(jù)庫的操作技巧,非常具有實用價值,需要的朋友可以參考下
本文實例講述了php實現(xiàn)redis數(shù)據(jù)庫指定庫號遷移的方法,分享給大家供大家參考。具體如下:
redis普通的數(shù)據(jù)庫遷移,只能整個redis
save,或者利用主從,當然也可以安裝一個redis-dump,不過比較麻煩,這里提供一種php的腳本,實現(xiàn)指定庫號的遷移,其實也就是遍歷根據(jù)存儲類型,讀出來,插入新庫,效果是這樣:
代碼如下:
[root@localhost
~]#
php
1.php
1/407
101/407
201/407
301/407
401/407
PHP實例代碼如下:
代碼如下:
?php
$from
=
'10.0.2.52:6379/7';
$to
=
'127.0.0.1:6379/7';
$from_redis
=
redis_init($from);
$to_redis
=
redis_init($to);
$keys
=
$from_redis-keys('*');
$count
=
0;
$total
=
count($keys);
foreach($keys
as
$key){
if(++$count
%
100
==
1){
echo
"$count/$totaln";
}
$type
=
$from_redis-type($key);
switch($type){
case
Redis::REDIS_STRING:
$val
=
$from_redis-get($key);
$to_redis-set($key,
$val);
break;
case
Redis::REDIS_LIST:
$list
=
$from_redis-lRange($key,
0,
-1);
foreach($list
as
$val){
$to_redis-rPush($key,
$val);
}
break;
case
Redis::REDIS_HASH:
$hash
=
$from_redis-hGetAll($key);
$to_redis-hMSet($key,
$hash);
break;
case
Redis::REDIS_ZSET:
$zset
=
$from_redis-zRange($key,
0,
-1,
true);
foreach($zset
as
$val=$score){
$to_redis-zAdd($key,
$score,
$val);
}
break;
}
}
function
redis_init($conf){
$redis
=
new
Redis();
preg_match('/^([^:]+)(:[0-9]+)?/(.+)?/',
$conf,
$ms);
$host
=
$ms[1];
$port
=
trim($ms[2],
':');
$db
=
$ms[3];
$redis-connect($host,
$port);
$redis-select($db);
return
$redis;
}
?
希望本文所述對大家的php程序設計有所幫助。
建表
phinx\bin\phinx.bat migrate -e production
建設 phinx.yml文件
paths:
migrations: %%PHINX_CONFIG_DIR%%\database\migrations
seeds: %%PHINX_CONFIG_DIR%%\database\seeds
environments:
default_migration_table: phinxlog
default_database: development
production:
adapter: mysql
host: localhost
name: jitamin2
user: root
pass: ‘‘
port: 3306
charset: utf8
development:
adapter: mysql
host: localhost
name: development_db
user: root
pass: ‘‘
port: 3306
charset: utf8
testing:
adapter: mysql
host: localhost
name: testing_db
user: root
pass: ‘‘
port: 3306
charset: utf8
數(shù)據(jù)遷移命令如下:
phinx\bin\phinx.bat seed:run -e production
%%PHINX_CONFIG_DIR%%\database\seeds下面的文件示例CreateGroupsTable.php如下:
?php
/*
* This file is part of Jitamin.
*
* Copyright (C) Jitamin Team
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Jitamin\Foundation\Security\Role;
use Phinx\Seed\AbstractSeed;
class UserSeeder extends AbstractSeed
{
/**
* Run Method.
*/
public function run()
{
$data = [
[
‘username‘ = ‘a(chǎn)dmin‘,
‘password‘ = bcrypt(‘a(chǎn)dmin‘),
‘email‘ = ‘a(chǎn)dmin@admin.com‘,
‘role‘ = Role::APP_ADMIN,
],
];
$users = $this-table(‘users‘);
$users-insert($data)
-save();
}
}
在下寫的轉 用戶的 程序,發(fā)出來給你參考下吧! 懸賞才5分,真吝嗇!
$next = intval($_GET['start']);
if ($next == NULL)
{
$next = 0;
}
$x = new Mysql($conf['xoops']);
$u = new Mysql($conf['ucenter']);
$start = $num*$next;
$m = $num*($next+1);
echo 'p/pfont color="red"開始轉換:第bfont color="blue"'.($start+1).'/font/b到bfont color="blue"'.$m.'/font/bbr/fonthr style="width:20%;" align="left" /';
//從xoops中提取數(shù)據(jù)
$sql = "SELECT `uid`,`uname`,`email`,`pass`,`user_regdate` FROM `{$xoops['prefix']}users` ORDER BY `uid` ASC LIMIT {$start},{$num}";
$rs = $x-oneRow($sql);
if(empty($rs)){
echo 'p/pfont color="blue"全部轉換完畢/font';
die();
}
$result = $x-query($sql);
while ($x_data = mysql_fetch_array($result,MYSQL_ASSOC)){
$user = $x_data;
//從ucenter中讀取數(shù)據(jù)
$sql = "SELECT `uid` FROM `".$ucenter['prefix']."members` WHERE `uid` = '".$user['uid']."' LIMIT 1";
$u_data = $u-oneRow($sql);
if(!empty($u_data)){
@$time_log = file_get_contents('uid_err_log.txt');
$time_log.="\r\n".'------------------------------------';
$time_log.="\r\n".'UID為'.$user['uid'].'的用戶'.$user['uname'].'在Ucente中已經(jīng)存在這個uid,可能已經(jīng)轉換過了。';
$time_log.="\r\n".'SQL語句:'.$sql;
$time_log.="\r\n".'------------------------------------';
@file_put_contents('uid_err_log.txt',$time_log);
}else{
$sql = "SELECT `uid` FROM `".$ucenter['prefix']."members` WHERE `username` = '".$user['uname']."' LIMIT 1";
$u_data = $u-oneRow($sql);
if (!empty($u_data)) {
echo 'br'.$user['uname'].'已經(jīng)在Ucenter中存在了!/b';
@$time_log = file_get_contents('uid_err_log.txt');
$time_log.="\r\n".'------------------------------------';
$time_log.="\r\n".'UID為'.$user['uid'].',用戶名為'.$user['uname'].'的用戶在xoops中已經(jīng)存在這個用戶名,可能已經(jīng)轉換過了。';
$time_log.="\r\n".'SQL語句:'.$sql;
$time_log.="\r\n".'------------------------------------';
@file_put_contents('uid_err_log.txt',$time_log);
}
}
//向Ucenter中插入用戶
$salt = substr(uniqid(rand()), -6);
$password = md5($user['pass'].$salt);
$sql = "INSERT INTO `".$ucenter['database']."`.`".$ucenter['prefix']."members` (`uid` ,`username` ,`password` ,`email` ,`myid` ,`myidkey` ,`regip` ,`regdate` ,`lastloginip` ,`lastlogintime` ,`salt` )
VALUES ('".$user['uid']."' , '".$user['uname']."', '".$password."', '".$user['email']."', '', '', '', '".$user['user_regdate']."', '0', '0', '".$salt."')";
if(!$u-query($sql)){
@$time_log = file_get_contents('insert_err_log.txt');
$time_log.="\r\n".'------------------------------------';
$time_log.="\r\n".'Ucenter插入新用戶錯誤';
$time_log.="\r\n".'SQL語句:'.$sql;
$time_log.="\r\n".'------------------------------------';
@file_put_contents('insert_err_log.txt',$time_log);
}
continue;
}
$next+=1;
echo 'meta http-equiv="Refresh" content="2; url=x2u.php?start='.$next.'" /';
exit();
?
當前名稱:php數(shù)據(jù)遷移解決方案,php數(shù)據(jù)遷移解決方案有哪些
本文URL:http://chinadenli.net/article10/dsgspdo.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設計公司、網(wǎng)站制作、品牌網(wǎng)站制作、定制開發(fā)、小程序開發(fā)、用戶體驗
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)