Solved

creating a mysql table for shared ip

Posted on 2013-05-26
13
323 Views
Last Modified: 2013-05-28
Dear Expert,
I have a cloud server that I host 5 web sites. I use cpanel and whm.
I have Centos operating system on my server. I created a database using Cpanel for one of my website.

I am trying to create a mysql table for the same website but when I use my ip addres for the connection string it can not connect it.

I have 5 domains 1 shared ip. I use below code to connect.

mysql_connect("my-shared-ipaddress", "username", "password") or die(mysql_error());
mysql_select_db("mydatabase") or die(mysql_error());

The error message is:

Warning: mysql_connect() [function.mysql-connect]: Host 'www.tavsiyevar.net' is not allowed to connect to this MySQL server in /home/alaramlz/public_html/test/CREATE_iletisim.php on line 11
Host 'www.tavsiyevar.net' is not allowed to connect to this MySQL server
0
Comment
Question by:Braveheartli
  • 4
  • 3
  • 3
  • +1
13 Comments
 
LVL 11

Expert Comment

by:RedLondon
ID: 39198118
Add www.tavsiyevar.net (and if that doesn't work, its IP address) to the Remote Database Access Hosts list for the database you're trying to connect to

To do that, in cPanel, click the Remote MySQL icon in the MySQL box, alongside the phpMyAdmin and MySQL Databases icon

If you don't see that icon, you may have to ask your server admin to do it for you (or if you have root access, you can give yourself access to Remote MySQL in the feature list)
0
 
LVL 11

Expert Comment

by:RedLondon
ID: 39198120
Is the username you're trying to use of the format cpanelusername_databaseusername ?  You need to be using the cPanel-generated database username and need to have granted it access to your database - it's not your FTP user details you need there.
0
 
LVL 12

Accepted Solution

by:
adrian_brooks earned 500 total points
ID: 39198180
This just sounds to me like you need to set up a user in your mysql database server that has permissions to either the entire server, a single database, one or more tables or whatever it is you want this user to have rights to.

That would just be a matter of executing the following two commands as MySQL queries;

GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost' IDENTIFIED BY 'some_password';

FLUSH PRIVILEGES;

Once you define a new user and flush the privileges, you should be able to connect as that user from any script on the system.

If you're needing to connect as yourself in a GUI like phpMyAdmin, then you will want to create a privilege for your user the same way.

If you only want a database user to connect via a specific IP, then you would modify the above grant statem to read like this;

GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'www.xxx.yyy.zzz.' IDENTIFIED BY 'some_password';

Hope this helped.

~AB
0
 
LVL 4

Expert Comment

by:Ahmed Hussein
ID: 39201185
You have to grant permissions to the database user on that IP, try  GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'www.domain.tld.' IDENTIFIED BY 'password';

or change www.domain.tld to the IP Address.
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 39202300
Dear RedLondon I did what you said and it didn't work.
the error message I recieve now is
Access denied for user 'alaramlz_ala'@'localhost' to database 'alaramlz_iletisim'
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 39202309
Dear adrian_brooks,
I have done what you said but I still can not access the database.
the error message is now " Access denied for user 'alaramlz_ala'@'localhost' to database 'alaramlz_iletisim' "
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Author Comment

by:Braveheartli
ID: 39202317
Dear AhmetGeek,
when I tried what you said, the error message is
#1044 - Access denied for user 'alaramlz'@'localhost' to database 'alaramlz_iletisim'
0
 
LVL 11

Expert Comment

by:RedLondon
ID: 39202324
Click "MySQL Databases" in cPanel

Does alaramlz_ala appear in the Users column for the database alaramlz_iletisim?

If not, use the "Add User To Database" section below to add it

If so, check that wherever you tell your script to use the alaramlz_ala username, that you have specified the correct password.

If you're not sure what the correct password is, and alaramlz_ala isn't used anywhere else, you could just use cPanel to delete the user, then recreate it with a password you make a note of, then add it to the alaramlz_iletisim database again.  If it is used elsewhere, you could just add a new user, give it permission to access the database using the same cPanel page, then set your script to use that new username and password.
0
 
LVL 12

Expert Comment

by:adrian_brooks
ID: 39202329
Did you do a 'FLUSH PRIVILEGES'?
0
 
LVL 4

Expert Comment

by:Ahmed Hussein
ID: 39202349
Try this.

GRANT ALL PRIVILEGES ON database_name.*TO 'user_name'@'IPADDRESS' 
    IDENTIFIED BY PASSWORD 'some_password' 
    WITH GRANT OPTION;
FLUSH PRIVILEGES;

Open in new window

0
 
LVL 12

Expert Comment

by:adrian_brooks
ID: 39202358
I don't think it's a good idea to do a with grant Orion for any user other than root and especially when doing a grant all on *.*
0
 
LVL 12

Expert Comment

by:adrian_brooks
ID: 39202365
Sorry, stupid cell phone auto correct bit my comment.
0
 
LVL 4

Expert Comment

by:Ahmed Hussein
ID: 39202370
adrian_brooks Yeeep I changed it :D
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now