I am trying all solution but I am able to connect to mysql Database in WAMP Server.
Question : I have created my webConfig but I am not able to connect to my Mysql database ?
Answer:
1 step : Go to C:\wamp\www\testmysql.php and try
<?php
$link = mysql_connect("localhost:3306","root",""); or use 8080
if (!$link) {
die('Could not connect to MySQL: ' . mysql_error());
}
echo 'Connection OK';
mysql_close($link);
?>
2 step : Go to your webconfig file in your Website folder
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'collegetpoint'); ..........your database name
/** MySQL database username */
define('DB_USER', 'root'); .............database user
/** MySQL database password */
define('DB_PASSWORD', ''); ................not need
/** MySQL hostname */
define('DB_HOST', 'localhost:3306');..............as per above
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
3 step:
After all this changes run the Server and test for Database again.
Every time it display DATABASE NOT CONNECTED.
In this blog i am giving you the solution of most common problem arises while using MySql in WAMP Server.Question : I have created my webConfig but I am not able to connect to my Mysql database ?
Answer:
1 step : Go to C:\wamp\www\testmysql.php and try
<?php
$link = mysql_connect("localhost:3306","root",""); or use 8080
if (!$link) {
die('Could not connect to MySQL: ' . mysql_error());
}
echo 'Connection OK';
mysql_close($link);
?>
2 step : Go to your webconfig file in your Website folder
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'collegetpoint'); ..........your database name
/** MySQL database username */
define('DB_USER', 'root'); .............database user
/** MySQL database password */
define('DB_PASSWORD', ''); ................not need
/** MySQL hostname */
define('DB_HOST', 'localhost:3306');..............as per above
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
3 step:
After all this changes run the Server and test for Database again.
Appreciation for nice Post.Thanks for all your step by step process on this Database connection.
ReplyDeleteI workout this step but not worked
ReplyDeletehelp me I am getting error .
ReplyDeleteThe character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. login_exec.php
i like your blog post thanks for share How create Database connection in php using wamp server
ReplyDelete