quick mysql question (using hostnames)

Just a quick one:

When setting up mysql, I can do this:

# mysqladmin -u root password '******'

But when I try to use a hostname in there, I get this:

# mysqladmin -u root -h example.host password '*****'
mysqladmin: connect to server at 'example.host' failed
error: 'Host 'example.host' is not allowed to connect to this MySQL server'

How might I get around this?

5 Replies

It appears that mysql isn't running. The database server needs to be running in order to update a database.

… or the "mysql" database has to be updated giving the user "root" access from the host "example.host". Either do this with "GRANT" after you logged in the mysql client or use "mysqladmin":

# mysqladmin -u root -h "example.host" password 'new-password'

If you do not specify the -h option, then the password is set globally for the root account.

@jax:

It appears that mysql isn't running. The database server needs to be running in order to update a database.

The thing is that the database server is running when I issue this command.

Sorry, read the first post wrong (I seem to do that frequently). If you take a look at the users table in the mysql database, you can specify different permissions to each user based on what host they logged in from. By default, root only has access to login from localhost. So, in order to specify anything else with -h, you first need to grant that access. Either manually insert a row into the table and flush the privileges, or refer to the mysql documentation to learn about GRANT.

http://dev.mysql.com/doc/mysql/en/Secure_GRANT.html

has any of you read my reply above? :roll:

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct