1
2

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.

mysqlをubuntu16.04に導入

Last updated at Posted at 2020-03-16

インストール

$ sudo apt install mysql-server mysql-client

一応↓もやった

$ sudo mysql_secure_installation

インストールを確認

$ mysql --version

一旦、ルート権限でmysqlにログイン
※パスワードはインストール時に設定したパスワードを

$ sudo mysql -u root -p

パスワードポリシーの設定を変更

mysql> SHOW VARIABLES LIKE 'validate_password%';
mysql> set global validate_password_length=6;
mysql> set global validate_password_mixed_case_count=0;

ユーザーを作成
登録したユーザーを確認
''をつけないとERROR

mysql> CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';
mysql> SHOW GRANTS FOR 'user_name'@'localhost';
mysql> select user,host from mysql.user;

試しにデータベースを作成

mysql> CREATE DATABASE test;

testデータベースにlocalhostからログインできるようにとりあえず全権限を付与
権限を確認
rootは怖いのでログアウト

mysql> GRANT ALL ON test.* TO 'user_name'@'localhost';
mysql> exit;

作成したユーザーでログインし直す

$ sudo mysql -u user_name -h localhost -p

参考
https://charlie1012.hatenablog.jp/entry/2015/09/05/170000
https://qiita.com/houtarou/items/a44ce783d09201fc28f5

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?