このWebサイト ひつじ帳 は、管理者がWEB関連の技術をまとめた備忘録サイトです。 Linux,CentOS,PHP,MySQL,Blogger,JavaScript,CSS について記録しています。

CentOS-7.1/MariaDB(MySQL)/設定

[ CentOS-7.1 ] [ MariaDB ] [ MariaDB インストール ]

MariaDB(MySQL) 設定

MariaDB(MySQL) 設定ファイル 編集

/etc/my.cnf.d/server.cnf


##■ 設定ファイルをバックアップ
[root@localhost ~]# cp -a /etc/my.cnf.d/server.cnf /etc/my.cnf.d/server.cnf.org
[root@localhost ~]#

##■ 設定ファイルを編集する
[root@localhost ~]# vi /etc/my.cnf.d/server.cnf

--------------------------------------------------
[mysqld]
##★ 追記する MariaDBサーバーの文字コードをUTF-8にする
character-set-server = utf8

##★ 追加する デフォルトのストレージエンジンを innodb にする
default-storage-engine = innodb
--------------------------------------------------

##■ 保存して編集終了
:wq
[root@localhost ~]#

##■ MariaDB 再起動
[root@localhost ~]# systemctl restart mariadb.service
[root@localhost ~]#

MariaDB(MySQL) 初期設定


##■ MariaDBを初期設定する
[root@localhost ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: 行 379: find_mysql_client: コマンドが見つかりません

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we’ll need the current
password for the root user.  If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):      <--★ "未入力"で [Enter]
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n]      <--★ "未入力"または"Y"を入力して [Enter] (※ rootパスワード設定)
New password:      <--★ rootパスワードを入力して [Enter] (※ 入力したパスワードは記録しておくこと)
Re-enter new password:      <--★ 上記と同じパスワードを入力して [Enter]
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n]      <--★ "未入力"または"Y"を入力して [Enter] (※ 匿名ユーザー削除)
 ... 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? [Y/n]      <--★ "未入力"または"Y"を入力して [Enter] (※ rootユーザーのリモートログインの禁止)
 ... Success!

By default, MariaDB 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? [Y/n]      <--★ "未入力"または"Y"を入力して [Enter] (※ 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? [Y/n]      <--★ "未入力"または"Y"を入力して [Enter] (※ 権限の変更を再読み込み)
 ... Success!

Cleaning up...

All done!  If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

MariaDB(MySQL) 接続確認


##■ root ユーザーで、接続する
[root@localhost ~]# mysql -u root -p
Enter password:      <--★ rootパスワードを入力して [Enter] (※ 入力した内容は表示されない)
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

##■ バージョンを表示
MariaDB [(none)]> select version();
+----------------+
| version()      |
+----------------+
| 5.5.41-MariaDB |
+----------------+
1 row in set (0.00 sec)

##■ データーベース一覧を表示
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

##■ データーベース"mysql"の中の"user"テーブルの情報を表示
MariaDB [(none)]> select user,host from mysql.user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1       |
| root | localhost |
+------+-----------+
3 rows in set (0.00 sec)

##■ 切断する
MariaDB [(none)]> exit
Bye
[root@localhost ~]#




以上で、MariaDB(MySQL)の設定は完了です。


[ MariaDB ]

0 件のコメント:

人気記事

このブログを検索