1.注意修改一下主机ip,端口,用户,密码,数据库名,si<400000改成自己设定的数据库量
<?php $conf = array( 'host'=>'192.168.0.100', 'port'=>3307, 'user'=>'proxyadmin', 'password'=>'oneproxy', 'database'=>'user_db' ); $dsn = 'mysql:dbname='.$conf['database'].';host='.$conf['host'].';port='.$conf['port'].';charset=UTF8'; try{ $dbh = new PDO($dsn, $conf['user'], $conf['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')); } catch(PDOException $e){ echo 'ERROR: ' . $e->getMessage(); exit; } $idx = 0; for ($i = 1; $i<=400000; $i++) { $account = 'shixinke'.$i; $password = md5($account.$i); $sql = 'INSERT INTO m_user_info(uid, account, password) VALUES('.$i.', "'.$account.'", "'.$password.'")'; $res = $dbh->exec($sql); if ($res) { $idx ++; } else { var_dump($dbh->errorInfo()); } } echo $idx;