用PHP来清空MYSQL数据库及其mysql连接数优化

jackxiang 2010-2-28 20:11 | |
<?php                    
                  
$user = ""; //数据库用户名                    
$password = "";//数据库密码                    
$db_name = "i";//数据库名                    
                  
$link = mysql_connect("localhost:3306",$user,$password);                    
mysql_select_db("$db_name",$link);                    
echo "<p>正在清空数据库,请稍等....<br>";                    
$result=mysql_query("SHOW tables",$link);                    
while ($currow=mysql_fetch_array($result)) {                    
mysql_query("drop TABLE IF EXISTS $currow[0]");                    
echo $currow[0]."<br>";                    
}                    
echo "<br>恭喜你清理MYSQL成功<br>";                    
?>



2.转一个优化的my.ini[mysql].1500在线.突破最大连接数,windows下的mysql,不敢保证可行性,呵呵

[mysqld]
basedir=D:/mysql
#bind-address=ip
datadir=D:/mysql/data
#language=D:/mysql/share/your language directory
#slow query log#=
#tmpdir#=
#port=3306
set-variable    = max_connections=1500
skip-locking
#skip-networking
set-variable        = key_buffer=384M
set-variable        = max_allowed_packet=1M
set-variable        = table_cache=512
set-variable        = sort_buffer=2M
set-variable        = record_buffer=2M
set-variable        = thread_cache=8
# Try number of CPU's*2 for thread_concurrency
set-variable        = thread_concurrency=8
set-variable        = myisam_sort_buffer_size=64M
#set-variable        = connect_timeout=5
#set-variable        = wait_timeout=5
server-id        = 1
[isamchk]
set-variable        = key_buffer=128M
set-variable        = sort_buffer=128M
set-variable        = read_buffer=2M
set-variable        = write_buffer=2M
[myisamchk]
set-variable        = key_buffer=128M
set-variable        = sort_buffer=128M
set-variable        = read_buffer=2M
set-variable        = write_buffer=2M
[WinMySQLadmin]
Server=D:/mysql/bin/mysqld-nt.exe

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/2742/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2010-2-28 20:13
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]