0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

サーバーにデプロイしたjavaWebAPとDBの接続

Last updated at Posted at 2021-09-06

MySQLにAP専用ユーザーとデータベース、テーブルを作成する

【本忘備録目的】
SpringBootで作成したjavaWebAPをサーバー側にデプロイしたのち、そのjavaWebAPと連携するDBを構築する。

|環境||
|----|----|----|
|OS|Linux ubuntu20.04|
|Web_S|apache|
|App_S|tomcat|
|DB_S|MySQL|

ポイント

  • サーバー側のMySQLにAP用のユーザーDB,パスワード等を設定する。
  • AP側のDBに関するプロパティファイルの内容(DBユーザー名とパスワード)をサーバー側の内容と合ううように変更する
sudo mysql
  • MySQL 5.7(またそれ以降のバージョン)を実行しているUbuntuシステムでは、rootMySQLユーザーはデフォルトによりパスワードではなくauth_socketプラグインを使用して認証するように設定されています。【中略】

MySQLにAP専用ユーザー作成

CREATE USER 'AP専用ユーザー'@'%' IDENTIFIED WITH mysql_native_password BY '任意のパスワード';

@'%'はホスト名を表す。

以下詳細
https://qiita.com/YuichiTanaka007/items/f31f94ace4bac0aaf990#%E3%83%9B%E3%82%B9%E3%83%88%E5%90%8D

MySQLにAP専用ユーザーにグローバル権限を付与する

専用ユーザーでDBやテーブルの作成等ができるようにグローバル権限を付与する

GRANT ALL ON 特定のDB名.* TO 'AP専用ユーザー'@'%';

GRANT ALL ON 特定のDB名.* TO 'AP専用ユーザー'@'%';

部分 説明 備考
GRANT 権限を与える
ALL グローバル権限
ON 特定のDB名.* 特定のDBの全ての権限 ON db_name.* 構文
'AP専用ユーザー'@'%'; AP専用ユーザーに対して
【ポイント】
・「特定のDB名」はこれから作るDB名を指定してOK。
・ 先にGRANTしないと権限がないので、DB等の作成ができない。

0
0
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?