PDA

View Full Version : سوال: کانکت شدن به mysql از یک سایت دیگر



zoro21750
یک شنبه 19 تیر 1384, 22:04 عصر
سلام.
چه جوری میشه از بیرون سایت به یه دیتابیس تو mysql کانکت شد؟
من این اررور اکسس دیناید رو میگیرم:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'MYUSERNAME@81.12.76.34' (Using password: YES) in C:\apachefriends\xampp\htdocs\test.php on line 21

81.12.76.34: آی پی منه، نه سایت اصلی. آی پی سایت یه چیز دیگست.
راستی سایت لینوکسه و از cpanel استفاده میکنه. در خود سایت، هاست به صورت localhost تعریف شده.

اگه اینجوری نشه، باید یه صفحه واسطه بنویسم که اطلاعاتو بگیره و این خیلی بده!

پ.ن.: برنامه نویس.ارگ قبلا ها قشنگ تر بود!

zoro21750
یک شنبه 19 تیر 1384, 23:30 عصر
راهشو پیدا کردم: از http://dev.mysql.com/doc/mysql/en/access-denied.html
Posted by David Morris on December 13 2003 10:16am]


+++SIMPLE CPANEL SOLUTION++++
If you get this error message
"Access denied for user: 'root@localhost' (Using password: YES)"

Then this may work for you.

When connecting to the MySQL server from a remote location You have to specify the "hosts"(remote location IP's) that you will be accessing the database from.

You must have access to CPANEL and have MySQL features enabled for this solution to work. A simple way to check if you have these features is to go into the CPANEL and look for the MySQL Databases Section.

If you have it listed, go into it.

Down towards the bottom of the page that loads you will see a heading called "Access Hosts".

By default you will only see "localhost" listed below this heading. This means only database access from the localhost(yourserver) is allowed.

You can add more hosts to this list by using the text box provided with the title "Host:"

For Example: if you wanted to give access to the MySQL server to a remote computer with this static IP address: 211.233.2.24 all you would simply do is type in the IP address in the textbox and hit the "add host" button.

If you had an entire network that you needed to give access to the MySQL server simply use the wildcard "%" symbol eg. 211.233.2.%

SECURITY WARNING: If you do not have a static IP address, using a wildcard "%" may open a security hole that can lead to unauthorized access to the MySQL server from a remote address. Make certain you delete all added hosts if you are not intending on using them and only set up wildcards if no one outside your network has access to the IP range you have specified.