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

備忘録 CentOS7 mySQL構築

Last updated at Posted at 2020-02-22

##リポジトリの確認

yum repolist all | grep mysql

##MySQLインストール

yum install mysql-community-server

##起動、起動確認

systemctl start mysqld.service
systemctl status mysqld.service

##永続化、永続化確認

systemctl enable mysqld.service
systemctl is-enabled mysqld.service

##インストール時にrootのパスワードがlogに吐かれているのでgrep


grep password /var/log/mysqld.log

---------------------------------------------------------
出力されるログ:
---------------------------------------------------------
2019-07-11T05:15:43.436113Z 5 [Note] [MY-010454] [Server]
 A temporary password is generated for
 root@localhost: G2Y%RSazYr1t
---------------------------------------------------------
パスワード = G2Y%RSazYr1t
---------------------------------------------------------

##各種設定

(パスワードの更新等)
mysql_secure_installation

★ポリシー違反しないパスワードの例
passwordPASSWORD@999

##ログイン

mysql -u root -p

##パスワードの仕様詳細表示
SHOW VARIABLES LIKE 'validate_password%';
##パスワードを弱くする
SET GLOBAL validate_password.policy=LOW;
SET GLOBAL validate_password.length=4;

##ユーザ権限確認

use mysql
select user,host from mysql.user;

##権限を変更

rename user root@localhost to root@'%';

quit
************************************************************
bye

##CentOS7 ファイアウォール設定

firewall-cmd --add-service=ssh --zone=public --permanent
firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --add-service=https --zone=public --permanent

##ポート開放

firewall-cmd --add-port=3306/tcp --zone=public --permanent

##許可するサービスの追加と削除

firewall-cmd --add-service=mysql --zone=public --permanent
//firewall-cmd --remove-service=mysql --zone=public --permanent

##firewalldのリロード

firewall-cmd --reload

##許可されているサービスやポートの一覧を表示

firewall-cmd --list-all --zone=public
firewall-cmd --list-services --zone=public
firewall-cmd --list-ports --zone=public

##ip addr

192.168.227.130
2
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
2
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?