CentOS7にMySQLをインストールする
リポジトリの追加
yumでインストールできるようにするためリポジトリを追加します。rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
リポジトリの確認
yumリポジトリが追加されているか確認。yum repolist all | grep mysql
リストにMySQL x.x Community Serverがあれば良い
MySQLのインストール
yum install mysql-community-server
MySQLのバージョン確認
mysqld --version
MySQLの起動
systemctl start mysqld
ログインパスワードの確認
grep 'temporary password' /var/log/mysqld.log
MySQLのセキュリティ設定
mysql_secure_installationを入力するmysql_secure_installation
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:
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
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 # rootパスワードの変更確認
New password:
Re-enter new password:
Estimated strength of the password: 100
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 # リモートからrootユーザーでのログイン
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 # testテーブルの削除
- Dropping test database...
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!
MySQLへのログイン
mysql -u root -p
コマンド入力、Enter、新しいパスワードを入力してEnter
MySQLの操作
show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
テーブルが表示できればよし。抜けるときはexitで抜ける
MySQLの停止
systemctl stop mysqld
参考
公式のリポジトリの追加・インストール等https://dev.mysql.com/downloads/repo/yum/
https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
ディスカッション
コメント一覧
まだ、コメントがありません