LoginSignup
0
0

More than 5 years have passed since last update.

mysql create userで指定するhostの意味

Posted at

SQLを久しぶりに触った時に忘れているのでメモします。

createuser.sql
CREATE USER 'exampleusername'@'examplehostname.com' IDENTIFIED BY 'examplepassword';

上記のようにユーザーを作成した際に指定している
examplehostname.com
↑この部分ですが
ホストを指定しているということはわかりますが
なんとなくホストを指定しているぐらいの認識でした。

厳密には
examplehostname.com
からしかアクセスができなくするという設定となります。

したがって以下のようにアクセスしてもエラーとなります。

[vagrant@localhost html]$ mysql -u exampleusername -p -h examplehostname.com
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'examplehostname.com' (110)

今回はローカルでの環境設定なので
localhostと設定して解決しました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0