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 '' is not allowed to connect to this MySQL server in /home/alaramlz/public_html/test/CREATE_iletisim.php on line 11
Host '' is not allowed to connect to this MySQL server
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Richard DavisConnect With a Mentor Senior 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';


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'@'' IDENTIFIED BY 'some_password';

Hope this helped.

Add (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)
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.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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.
BRMarketingAuthor 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'
BRMarketingAuthor 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' "
BRMarketingAuthor Commented:
Dear AhmetGeek,
when I tried what you said, the error message is
#1044 - Access denied for user 'alaramlz'@'localhost' to database 'alaramlz_iletisim'
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.
Richard DavisSenior Web DeveloperCommented:
Did you do a 'FLUSH PRIVILEGES'?
Ahmed HusseinCommented:
Try this.

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

Open in new window

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 *.*
Richard DavisSenior Web DeveloperCommented:
Sorry, stupid cell phone auto correct bit my comment.
Ahmed HusseinCommented:
adrian_brooks Yeeep I changed it :D
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.