Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

creating a mysql table for shared ip

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
Braveheartli
Asked:
Braveheartli
  • 4
  • 3
  • 3
  • +1
1 Solution
 
RedLondonCommented:
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
 
RedLondonCommented:
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
 
Richard DavisSenior Web DeveloperCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Ahmed HusseinCommented:
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
 
BraveheartliMarketingAuthor Commented:
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
 
BraveheartliMarketingAuthor Commented:
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
 
BraveheartliMarketingAuthor Commented:
Dear AhmetGeek,
when I tried what you said, the error message is
#1044 - Access denied for user 'alaramlz'@'localhost' to database 'alaramlz_iletisim'
0
 
RedLondonCommented:
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
 
Richard DavisSenior Web DeveloperCommented:
Did you do a 'FLUSH PRIVILEGES'?
0
 
Ahmed HusseinCommented:
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
 
Richard DavisSenior Web DeveloperCommented:
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
 
Richard DavisSenior Web DeveloperCommented:
Sorry, stupid cell phone auto correct bit my comment.
0
 
Ahmed HusseinCommented:
adrian_brooks Yeeep I changed it :D
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now