php数据迁移解决方案,php数据迁移解决方案有哪些

php网站搭建的数据库如何转移

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

10年的民丰网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整民丰建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联公司从事“民丰网站设计”,“民丰网站推广”以来,每个客户项目都认真落实执行。

然后再B中新建Q2,create database Q2

应用Q2 use Q2

导入Q1 source Q1.sql

赋予用户 grant all privileges on Q2.* to 'admin2'@localhost identified by 'admin2222'

这样就可以了!

php实现redis数据库指定库号迁移的方法

这篇文章主要介绍了php实现redis数据库指定库号迁移的方法,涉及对于redis数据库的操作技巧,非常具有实用价值,需要的朋友可以参考下

本文实例讲述了php实现redis数据库指定库号迁移的方法,分享给大家供大家参考。具体如下:

redis普通的数据库迁移,只能整个redis

save,或者利用主从,当然也可以安装一个redis-dump,不过比较麻烦,这里提供一种php的脚本,实现指定库号的迁移,其实也就是遍历根据存储类型,读出来,插入新库,效果是这样:

代码如下:

[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程序设计有所帮助。

如何在PHP项目中使用phinx进行数据迁移和建表

建表

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

数据迁移命令如下:

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‘ = ‘admin‘,

‘password‘ = bcrypt(‘admin‘),

‘email‘ = ‘admin@admin.com‘,

‘role‘ = Role::APP_ADMIN,

],

];

$users = $this-table(‘users‘);

$users-insert($data)

-save();

}

}

PHP如何使用表单将这个数据库数据转移到另一个数据去

在下写的转 用户的 程序,发出来给你参考下吧! 悬赏才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中提取数据

$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中读取数据

$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中已经存在这个uid,可能已经转换过了。';

$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'].'已经在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中已经存在这个用户名,可能已经转换过了。';

$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数据迁移解决方案,php数据迁移解决方案有哪些
网站URL:http://azwzsj.com/article/dsgspdo.html