代码如下:
<?php 
$link = mysql_connect("localhost","root","root") or die('Could not connect: ' . mysql_error());
        if(!$link) echo "false"; 
else echo "success"; 
mysql_close(); 
?> 返回如下错误:Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in E:\web\PHPCodes\mysql_test.php on line 2
Could not connect: Access denied for user 'SYSTEM'@'localhost' (using password: NO)使用mysql-front登录mysql(root/root)正常我查了很久都没有相关的解决办法。但发现mysql_connect()函数,默认参数是以进程用户名,空密码连接,可是我在代码中加入了参数为什么还以默认参数执行?请高手指点

解决方案 »

  1.   

    user 'SYSTEM'@'localhost'
    现在的用户不是你说的ROOT.当然密码不是你ROOT的密码了。
    仔细看你的错误提示。
    还有检查你的语句。
      

  2.   

    一般默认设置密码为空的,你试下。
    <?                            
    $link = mysql_connect('localhost', 'root', '');
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_close($link);
    ?>
      

  3.   

    怪就怪在这里,我的代码确是如上面所示用的root,但确提示用SYSTEM连接的。同时我发现mysql_connect()函数,默认参数是以进程用户名+空密码连接,正好与错误提示(SYSTEM+空密码)一致,不知是否有什么联系,为什么会用默认参数连库?怪哉,怪哉!
      

  4.   

    你看一下你的MY.INI或者MY.CNF里面是不是设置了默认用户?
      

  5.   

    顶,,问下楼主是什么系统,,我在Windows 2000下也报楼主的错误,,在Windows xp下就可以正常运行,,,我确认楼主代码没有问题
      

  6.   

    XP HOME版 sp2php-5.1.6-Win32,apache_2.2.4,mysql-5.0.24,ZendOptimizer-3.3.0a没有MY.CNF文件MY.INI文件如下,请高手看下设置是否有问题:
    [client]port=3306[mysql]default-character-set=latin1[mysqld]# The TCP/IP Port the MySQL Server will listen on
    port=3306
    #Path to installation directory. All paths are usually resolved relative to this.
    basedir="E:/web/MySQL5.0/"#Path to the database root
    datadir="E:/web/MySQL5.0/Data/"# The default character set that will be used when a new schema or table is
    # created and no character set is defined
    default-character-set=latin1# The default storage engine that will be used when create new tables when
    default-storage-engine=INNODB# Set the SQL mode to strict
    sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"max_connections=100
    query_cache_size=0
    table_cache=256
    tmp_table_size=5M
    thread_cache_size=8myisam_max_sort_file_size=100G
    myisam_max_extra_sort_file_size=100Gmyisam_sort_buffer_size=8M
    key_buffer_size=8M
    read_buffer_size=64K
    read_rnd_buffer_size=256Ksort_buffer_size=212K
    innodb_additional_mem_pool_size=2Minnodb_flush_log_at_trx_commit=1
    innodb_log_buffer_size=1Minnodb_buffer_pool_size=8M
    innodb_log_file_size=10M
    innodb_thread_concurrency=8