Php cannot connect to mysql, but Nvicat can

Source: Internet
Author: User
Tags php database
Php cannot connect to mysql, but Nvicat can. $ Db = mysql_connect ("124.172.118.122", & nbsp; "dbcms_f", "123456"); if & nbsp ;(! $ Db) {die ('& lt; br & gt; connection error: & nbsp;' & php cannot connect to mysql, but Nvicat can.
$ Db = mysql_connect ("124.172.118.122", "dbcms_f", "123456 ");
If (! $ Db)
{
Die ('
Connection error: '. mysql_error ());
}
$ Sqlname = "dbcmxs"; // database name
Mysql_select_db ($ sqlname, $ db) or die ("link error !! "); // Connect to the database
Session_start ();
Mysql_query ("set names 'utf8'", $ db); // defines the language format of data interaction.

The error message is

Warning: mysql_connect () [function. mysql-connect]: Premature end of data (mysqlnd_wireprotocol.c: 553) in D: \ workspace \ php \ fww \ phpcms \ inc \ conn. php on line 2

Warning: mysql_connect () [function. mysql-connect]: OK packet 1 bytes shorter than expected in D: \ workspace \ php \ fww \ phpcms \ inc \ conn. php on line 2

Warning: mysql_connect () [function. mysql-connect]: mysqlnd cannot connect to MySQL 4.1 + using the old insecure authentication. please use an administration tool to reset your password with the command set password = PASSWORD ('your _ existing_password '). this will store a new, and more secure, hash value in mysql. user. if this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my. cnf file in D: \ workspace \ php \ fww \ phpcms \ inc \ conn. php on line 2

Connection error: mysqlnd cannot connect to MySQL 4.1 + using the old insecure authentication. please use an administration tool to reset your password with the command set password = PASSWORD ('your _ existing_password '). this will store a new, and more secure, hash value in mysql. user. if this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my. cnf file

Below is my remote mysql information
Server version: 5.5.20
Protocol version: 10
Server: Localhost via UNIX socket
User: ***) *** @ localhost
MySQL character set: cp1252 West European (latin1)
 
Create a new database:
No permission


MySQL PHP database server
------ Solution --------------------
Warning MYSQL_CONNECT () [function. mysql connection]: early termination of data in D (mysqlnd_wireprotocol.c: 553): \ workspace \ PHP \ INC \ conn. php \ FWW \ PHPCMS online 2

Warning MYSQL_CONNECT () [connection]: OK package 1 byte less than expected in D: \ workspace \ PHP \ FWW \ PHPCMS \ INC \ conn. php2 line

Warning MYSQL_CONNECT () [function. mysql connection mysqlnd cannot connect to MySQL4.1 + use old insecure authentication. Use the administrative tool to reset the PASSWORD ('your _ existing_password ') of the set password = command '). This will store a new, safer, and hash value in mysql. user. If this user uses another script to execute PHP5.2 or earlier, you may need to delete the old password flag line 2 from my. the cnf file is in D: \ workspace, \ PHPCMS \ INC \ conn of \ php \ FWW. php

The connection error mysqlnd cannot connect to MySQL4.1 + and use the old insecure authentication. Use the administrative tool to reset the PASSWORD ('your _ existing_password ') of the set password = command '). This will store a new, safer, and hash value in mysql. user. If this user executes PHP5.2 or earlier in other scripts, you may need to delete the old password flag from your my. cnf file.

Is your php version too low or your mysql version too high?
------ Solution --------------------
According to the error message, the mysql client version in php is too low.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.