背景
仮想環境に慣れていくために、mysqlのインストールと、少し動かしてみようと思う
仮想環境の構築
- 仮想環境は以前の記事で作成したものを使用する
https://qiita.com/fsd-ishihara/items/e7d7d7bd78391aa567df
mysqlのインストール
- mariadb-libsがあるかどうかの確認
yum list | grep mariadb-libs* - あったら削除を実行する
yum remove mariadb-libs - リポジトリのインストール
rpm -ivh http://dev.mysql.com/get/mysql80-community-release-el7-9.noarch.rpm
※このコマンドは環境によって変わる - mysqlのインストール
yum install mysql-community-server - インストールできたか確認
mysqld --version
起動させてみる
- 起動コマンド
systemctl start mysqld - 起動の確認コマンド、runningという文字が入っていれば、起動済み
systemctl status mysqld - 停止コマンド、使い終わったら停止させること
systemctl stop mysqld
ログインしてみる
- mysqlのパスワードを確認する⇒root@localhost:[パスワード]という風に表示される
cat /var/log/mysqld.log | grep root - 上記のパスワードを使いログインする
mysql -u root -p - こうするとパスワードが要求されるため、先ほど確認したパスワードを入力
mysqlを動かすためにパスワードを変更
- パスワードを変更しないと、sqlを流す際にはじかれる
- パスワードを変更手順
Securing the MySQL server deployment.
Enter password for user root: 初期パスワードを入力する
The existing password for the user account root has expired. Please set a new password.
New password: 新しいパスワードを入力する
Re-enter new password: 再度同じ新しいパスワードを入力する
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password: ポリシーに沿った新しいパスワードを入力
Re-enter new password: 再度新しいパスワードを入力する
Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!