LoginSignup
0
1

More than 5 years have passed since last update.

mac上の仮想環境に構築したcentos7にmysqlを導入する

Last updated at Posted at 2017-05-15

mariaDBの削除

CentOS7では最初からmariaDBが導入されていることがあります。これはMySQL互換のDBですが今回はオリジナルのMySQLを利用するため、もともと導入されているmariaDBはアンイストールしておきます。
導入されているかの確認をrpmコマンドで行います。

[vagrant@localhost bin]$ rpm -qa|grep -i mariadb
mariadb-libs-5.5.41-2.el7_0.x86_64

導入されていましたので削除します。

[vagrant@localhost bin]$ sudo yum remove mariadb-libs

削除完了

MySQLの導入

yumを利用してMySQLを導入します。

[vagrant@localhost bin]$ sudo yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm

導入が完了したらバージョンを確認します。

[vagrant@localhost bin]$ mysqld -V
mysqld  Ver 5.6.36 for Linux on x86_64 (MySQL Community Server (GPL))

導入できました。

MySQLの起動と停止

サービスの登録

MySQLのデーモンをシステムが起動したときに自動的に起動するようにするためにサービスへ登録します。

[vagrant@localhost ~]$ sudo systemctl enable mysqld.service
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on

なんかエラーが出たみたいなメッセージですが登録されています。
サービスの確認はchekconfigコマンドを利用します。

[vagrant@localhost ~]$ sudo /sbin/chkconfig --list

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
vboxadd         0:off   1:off   2:on    3:on    4:on    5:on    6:off
vboxadd-service 0:off   1:off   2:on    3:on    4:on    5:on    6:off
vboxadd-x11     0:off   1:off   2:off   3:on    4:off   5:on    6:off

mysqldがサービスとして登録されています。数字はrunlevelというもので、OSの起動モードごとにそのサービスを起動するのかどうかが定義できます。mysqldのこの設定は、マルチユーザーモードのときには起動するという意味になります。

mysqldの起動

サービスとして登録したので、systemctlコマンドで起動します。

[vagrant@localhost ~]$ sudo systemctl start mysqld.service

mysqldの起動確認

/var/log/mysqld.logにデーモンのログが書き込まれるため確認します。

[vagrant@localhost ~]$ tail -f /var/log/mysqld.log
2017-05-11 19:35:28 1949 [Note] InnoDB: 128 rollback segment(s) are active.
2017-05-11 19:35:28 1949 [Note] InnoDB: Waiting for purge to start
2017-05-11 19:35:28 1949 [Note] InnoDB: 5.6.36 started; log sequence number 1626077
2017-05-11 19:35:28 1949 [Note] Server hostname (bind-address): '*'; port: 3306
2017-05-11 19:35:28 1949 [Note] IPv6 is available.
2017-05-11 19:35:28 1949 [Note]   - '::' resolves to '::';
2017-05-11 19:35:28 1949 [Note] Server socket created on IP: '::'.
2017-05-11 19:35:28 1949 [Note] Event Scheduler: Loaded 0 events
2017-05-11 19:35:28 1949 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.36'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

無事に起動していました。

mysqldの停止

[vagrant@localhost ~]$ sudo systemctl stop mysqld.service

mysqldの停止確認

同じくログファイルを確認します。

[vagrant@localhost ~]$ tail -f /var/log/mysqld.log
2017-05-15 14:45:38 1949 [Note] Shutting down plugin 'MyISAM'
2017-05-15 14:45:38 1949 [Note] Shutting down plugin 'CSV'
2017-05-15 14:45:38 1949 [Note] Shutting down plugin 'MEMORY'
2017-05-15 14:45:38 1949 [Note] Shutting down plugin 'MRG_MYISAM'
2017-05-15 14:45:38 1949 [Note] Shutting down plugin 'sha256_password'
2017-05-15 14:45:38 1949 [Note] Shutting down plugin 'mysql_old_password'
2017-05-15 14:45:38 1949 [Note] Shutting down plugin 'mysql_native_password'
2017-05-15 14:45:38 1949 [Note] Shutting down plugin 'binlog'
2017-05-15 14:45:38 1949 [Note] /usr/sbin/mysqld: Shutdown complete

正常に停止しました。

参考

macOS Sierra バージョン10.12.4
Vagrant 1.9.4
VirtualBox 5.1.22
CentOS 7.0 64bit
MySQL 5.6.36


シリーズ一覧 (vagrant centos LAMP環境構築)

1.macにvagrantでcentos7の仮想環境を構築したときの初期設定
2.mac上の仮想環境に構築したcentos7にPHPを導入する
3.mac上の仮想環境に構築したcentos7でPHPのビルトインサーバーを利用する
4.mac上の仮想環境に構築したcentos7にapahceを導入する
5.mac上の仮想環境に構築したcentos7にmysqlを導入する
6.centos7に導入したMySQL5.6の初期設定と動作確認

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