#author("2018-05-04T17:53:32+09:00","","")
#author("2018-05-04T17:56:46+09:00","","")
#nofollow
#norelated
総数:&counter(total); 今日:&counter(today); 昨日:&counter(yesterday);

* もくじ [#s0c4d700]

#contents

*mysql-server パッケージのインストール [#v289f474]
 ~$ sudo apt-get -y install mysql-server

 パッケージリストを読み込んでいます... 完了
 依存関係ツリーを作成しています                
 状態情報を読み取っています... 完了
 以下の追加パッケージがインストールされます:
   libaio1 libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common
   mysql-server-5.7 mysql-server-core-5.7
 提案パッケージ:
   libipc-sharedcache-perl mailx tinyca
 以下のパッケージが新たにインストールされます:
   libaio1 libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server
   mysql-server-5.7 mysql-server-core-5.7
 アップグレード: 0 個、新規インストール: 9 個、削除: 0 個、保留: 134 個。
 18.1 MB のアーカイブを取得する必要があります。
 この操作後に追加で 161 MB のディスク容量が消費されます。
 取得:1 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-common all 5.7.22-0ubuntu0.16.04.1 [15.4 kB]
 取得:2 http://jp.archive.ubuntu.com/ubuntu xenial/main amd64 libaio1 amd64 0.3.110-2 [6,356 B]
 取得:3 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-client-core-5.7 amd64 5.7.22-0ubuntu0.16.04.1 [6,425 kB]
 取得:4 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-client-5.7 amd64 5.7.22-0ubuntu0.16.04.1 [1,673 kB]
 取得:5 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-server-core-5.7 amd64 5.7.22-0ubuntu0.16.04.1 [7,268 kB]
 取得:6 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libevent-core-2.0-5 amd64 2.0.21-stable-2ubuntu0.16.04.1 [70.6 kB]
 取得:7 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-server-5.7 amd64 5.7.22-0ubuntu0.16.04.1 [2,583 kB]
 取得:8 http://jp.archive.ubuntu.com/ubuntu xenial/main amd64 libhtml-template-perl all 2.95-2 [60.4 kB]
 取得:9 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-server all 5.7.22-0ubuntu0.16.04.1 [10.8 kB]
 18.1 MB を 1秒 で取得しました (13.4 MB/s)
 パッケージを事前設定しています ...
 以前に未選択のパッケージ mysql-common を選択しています。
 (データベースを読み込んでいます ... 現在 185807 個のファイルとディレクトリがインストールされています。)
 .../mysql-common_5.7.22-0ubuntu0.16.04.1_all.deb を展開する準備をしています ...
 mysql-common (5.7.22-0ubuntu0.16.04.1) を展開しています...
 以前に未選択のパッケージ libaio1:amd64 を選択しています。
 .../libaio1_0.3.110-2_amd64.deb を展開する準備をしています ...
 libaio1:amd64 (0.3.110-2) を展開しています...
 以前に未選択のパッケージ mysql-client-core-5.7 を選択しています。
 .../mysql-client-core-5.7_5.7.22-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
 mysql-client-core-5.7 (5.7.22-0ubuntu0.16.04.1) を展開しています...
 以前に未選択のパッケージ mysql-client-5.7 を選択しています。
 .../mysql-client-5.7_5.7.22-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
 mysql-client-5.7 (5.7.22-0ubuntu0.16.04.1) を展開しています...
 以前に未選択のパッケージ mysql-server-core-5.7 を選択しています。
 .../mysql-server-core-5.7_5.7.22-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
 mysql-server-core-5.7 (5.7.22-0ubuntu0.16.04.1) を展開しています...
 以前に未選択のパッケージ libevent-core-2.0-5:amd64 を選択しています。
 .../libevent-core-2.0-5_2.0.21-stable-2ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
 libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) を展開しています...
 libc-bin (2.23-0ubuntu10) のトリガを処理しています ...
 man-db (2.7.5-1) のトリガを処理しています ...
 mysql-common (5.7.22-0ubuntu0.16.04.1) を設定しています ...
 update-alternatives: /etc/mysql/my.cnf (my.cnf) を提供するために自動モードで /etc/mysql/my.cnf.fallback を使います
 以前に未選択のパッケージ mysql-server-5.7 を選択しています。
 (データベースを読み込んでいます ... 現在 185975 個のファイルとディレクトリがインストールされています。)
 .../mysql-server-5.7_5.7.22-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
 mysql-server-5.7 (5.7.22-0ubuntu0.16.04.1) を展開しています...
 以前に未選択のパッケージ libhtml-template-perl を選択しています。
 .../libhtml-template-perl_2.95-2_all.deb を展開する準備をしています ...
 libhtml-template-perl (2.95-2) を展開しています...
 以前に未選択のパッケージ mysql-server を選択しています。
 .../mysql-server_5.7.22-0ubuntu0.16.04.1_all.deb を展開する準備をしています ...
 mysql-server (5.7.22-0ubuntu0.16.04.1) を展開しています...
 man-db (2.7.5-1) のトリガを処理しています ...
 ureadahead (0.100.0-19) のトリガを処理しています ...
 systemd (229-4ubuntu21.1) のトリガを処理しています ...
 libaio1:amd64 (0.3.110-2) を設定しています ...
 mysql-client-core-5.7 (5.7.22-0ubuntu0.16.04.1) を設定しています ...
 mysql-client-5.7 (5.7.22-0ubuntu0.16.04.1) を設定しています ...
 mysql-server-core-5.7 (5.7.22-0ubuntu0.16.04.1) を設定しています ...
 libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) を設定しています ...
 mysql-server-5.7 (5.7.22-0ubuntu0.16.04.1) を設定しています ...
 update-alternatives: /etc/mysql/my.cnf (my.cnf) を提供するために自動モードで /etc/mysql/mysql.cnf を使います
 Renaming removed key_buffer and myisam-recover options (if present)
 libhtml-template-perl (2.95-2) を設定しています ...
 mysql-server (5.7.22-0ubuntu0.16.04.1) を設定しています ...
 libc-bin (2.23-0ubuntu10) のトリガを処理しています ...
 systemd (229-4ubuntu21.1) のトリガを処理しています ...
 ureadahead (0.100.0-19) のトリガを処理しています ...
 
-(MySQLの "root" ユーザに対する新しいパスワード)で パスワードを入力して、了解 を選択する。
-(MySQLの "root" ユーザに対する新しいパスワード)で 再度パスワードを入力して、了解 を選択する。
-バージョン確認する。
 ~$ mysql --version
 mysql  Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using  EditLine wrapper
5.7.22 だ。

*php-mysql パッケージのインストール [#ae0d1a4d]
 ~$ sudo apt-get -y install php-mysql

 パッケージリストを読み込んでいます... 完了
 依存関係ツリーを作成しています                
 状態情報を読み取っています... 完了
 以下の追加パッケージがインストールされます:
   php-common php7.0-common php7.0-mysql
 以下のパッケージが新たにインストールされます:
   php-common php-mysql php7.0-common php7.0-mysql
 アップグレード: 0 個、新規インストール: 4 個、削除: 0 個、保留: 134 個。
 977 kB のアーカイブを取得する必要があります。
 この操作後に追加で 5,275 kB のディスク容量が消費されます。
 取得:1 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php-common all 1:35ubuntu6.1 [10.8 kB]
 取得:2 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php7.0-common amd64 7.0.28-0ubuntu0.16.04.1 [840 kB]
 取得:3 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php7.0-mysql amd64 7.0.28-0ubuntu0.16.04.1 [124 kB]
 取得:4 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php-mysql all 1:7.0+35ubuntu6.1 [1,928 B]
 977 kB を 0秒 で取得しました (3,500 kB/s)
 以前に未選択のパッケージ php-common を選択しています。
 (データベースを読み込んでいます ... 現在 186076 個のファイルとディレクトリがインストールされています。)
 .../php-common_1%3a35ubuntu6.1_all.deb を展開する準備をしています ...
 php-common (1:35ubuntu6.1) を展開しています...
 以前に未選択のパッケージ php7.0-common を選択しています。
 .../php7.0-common_7.0.28-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
 php7.0-common (7.0.28-0ubuntu0.16.04.1) を展開しています...
 以前に未選択のパッケージ php7.0-mysql を選択しています。
 .../php7.0-mysql_7.0.28-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
 php7.0-mysql (7.0.28-0ubuntu0.16.04.1) を展開しています...
 以前に未選択のパッケージ php-mysql を選択しています。
 .../php-mysql_1%3a7.0+35ubuntu6.1_all.deb を展開する準備をしています ...
 php-mysql (1:7.0+35ubuntu6.1) を展開しています...
 php-common (1:35ubuntu6.1) を設定しています ...
 php7.0-common (7.0.28-0ubuntu0.16.04.1) を設定しています ...
 
 Creating config file /etc/php/7.0/mods-available/calendar.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/ctype.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/exif.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/fileinfo.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/ftp.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/gettext.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/iconv.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/pdo.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/phar.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/posix.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/shmop.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/sockets.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/sysvmsg.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/sysvsem.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/sysvshm.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/tokenizer.ini with new version
 php7.0-mysql (7.0.28-0ubuntu0.16.04.1) を設定しています ...
 
 Creating config file /etc/php/7.0/mods-available/mysqlnd.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/mysqli.ini with new version
 
 Creating config file /etc/php/7.0/mods-available/pdo_mysql.ini with new version
 php-mysql (1:7.0+35ubuntu6.1) を設定しています ...
 
-バージョン確認する。
 ~$ dpkg -l | grep -i php-mysql
 ii  php-mysql                                  1:7.0+35ubuntu6.1                            all          MySQL module for PHP [default]

*mysql-client パッケージのインストール [#u6d1ed55]
 ~$ sudo apt-get -y install mysql-client

 パッケージリストを読み込んでいます... 完了
 依存関係ツリーを作成しています                
 状態情報を読み取っています... 完了
 以下のパッケージが新たにインストールされます:
   mysql-client
 アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 134 個。
 10.0 kB のアーカイブを取得する必要があります。
 この操作後に追加で 110 kB のディスク容量が消費されます。
 取得:1 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-client all 5.7.22-0ubuntu0.16.04.1 [10.0 kB]
 10.0 kB を 0秒 で取得しました (84.9 kB/s)
 以前に未選択のパッケージ mysql-client を選択しています。
 (データベースを読み込んでいます ... 現在 186166 個のファイルとディレクトリがインストールされています。)
 .../mysql-client_5.7.22-0ubuntu0.16.04.1_all.deb を展開する準備をしています ...
 mysql-client (5.7.22-0ubuntu0.16.04.1) を展開しています...
 mysql-client (5.7.22-0ubuntu0.16.04.1) を設定しています ...


*MySQL環境のセキュア化 [#z5afe761]
参考URL http://www.cyberciti.biz/faq/howto-install-mysql-on-ubuntu-linux-16-04/

**Run mysql_secure_installation to secure your installation [#v4a557ad]
For all production server you must run the following command:
 $ sudo mysql_secure_installation

 Securing the MySQL server deployment.
 
 Enter password for user root: 
パスワードを入力する。
 
 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:

enterキーを押す。

 Using existing password for root.
 Change the password for root ? ((Press y|Y for Yes, any other key for No) :

enterキーを押す。

  ... skipping.
 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) : 

enterキーを押す。

  ... skipping.
 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 キーを押す。

  - 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! 

*QA about mysql5.7 [#m92eb681]
**How do I use MySQL server? [#w7af9acb]
To log in as the root user, type:
 $ mysql -u root -p

 Enter password: 
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 6
 Server version: 5.7.22-0ubuntu0.16.04.1 (Ubuntu)
 
 Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
 
 Oracle is a registered trademark of Oracle Corporation and/or its
 affiliates. Other names may be trademarks of their respective
 owners.
 
 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
 mysql> exit
 Bye
 
**How do I create a new MySQL server database and user account? [#z488ed18]
The sql syntax is as follows to create a new mysql database and setup password:

 mysql> create database <DATABASE-NAME>;
 mysql> grant all on <DATABASE-NAME>.* to '<DATABASE-USERNAME>' identified by 'DATABASE-PASSWORD';
 mysql> quit;

Now, try to log in as vivek user, enter:
 $ mysql -u <DATABASE-USERNAME> -p <DATABASE-NAME>

**How do I start MySQL server? [#sfd84070]
 $ sudo systemctl start mysql

**How do I stop MySQL server? [#m33f87ed]
 $ sudo systemctl stop mysql

**How do I restart MySQL server? [#hf1fd73a]
 $ sudo systemctl restart mysql

**How do I find out if MySQL running/active? [#s3c59d7a]
 $ sudo systemctl status mysql.service

 ● mysql.service - MySQL Community Server
    Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
    Active: active (running) since 金 2018-05-04 17:27:36 JST; 19min ago
  Main PID: 5021 (mysqld)
    CGroup: /system.slice/mysql.service
            └─5021 /usr/sbin/mysqld
 
  5月 04 17:27:35 ubdt16044 systemd[1]: Starting MySQL Community Server...
  5月 04 17:27:36 ubdt16044 systemd[1]: Started MySQL Community Server.

**How do I reset the mysql root account password? [#b2435862]
 $ sudo dpkg-reconfigure mysql-server-5.7

**A note about MySQL server configuration [#n3dbe4a2]
You may edit the /etc/mysql/my.cnf file to configure the basic settings&br;
such as TCP/IP port, IP address binding, and other options.&br;
However, The MySQL database server configuration file on the Ubuntu 16.04 LTS is&br;
located at&br;
 /etc/mysql/mysql.conf.d/mysqld.cnf
and one can edit using a text editor such as gvim:&br;
 $ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
 $ sudo systemctl restart mysql.service

**データベース ディレクトリ構造の生成 [#q1704dff]
参考URL
https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html
***mysqld設定ファイルをみてデータの所在を知る [#d84fbdc1]
 ~$ cat /etc/mysql/mysql.conf.d/mysqld.cnf

 #
 # The MySQL database server configuration file.
 #
 # You can copy this to one of:
 # - "/etc/mysql/my.cnf" to set global options,
 # - "~/.my.cnf" to set user-specific options.
 # 
 # One can use all long options that the program supports.
 # Run program with --help to get a list of available options and with
 # --print-defaults to see which it would actually understand and use.
 #
 # For explanations see
 # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
 
 # This will be passed to all mysql clients
 # It has been reported that passwords should be enclosed with ticks/quotes
 # escpecially if they contain "#" chars...
 # Remember to edit /etc/mysql/debian.cnf when changing the socket location.
 
 # Here is entries for some specific programs
 # The following values assume you have at least 32M ram
 
 [mysqld_safe]
 socket		= /var/run/mysqld/mysqld.sock
 nice		= 0
 
 [mysqld]
 #
 # * Basic Settings
 #
 user		= mysql
 pid-file	= /var/run/mysqld/mysqld.pid
 socket		= /var/run/mysqld/mysqld.sock
 port		= 3306
 basedir		= /usr
 datadir		= /var/lib/mysql
 tmpdir		= /tmp
 lc-messages-dir	= /usr/share/mysql
 skip-external-locking
 #
 # Instead of skip-networking the default is now to listen only on
 # localhost which is more compatible and is not less secure.
 bind-address		= 127.0.0.1
 #
 # * Fine Tuning
 #
 key_buffer_size		= 16M
 max_allowed_packet	= 16M
 thread_stack		= 192K
 thread_cache_size       = 8
 # This replaces the startup script and checks MyISAM tables if needed
 # the first time they are touched
 myisam-recover-options  = BACKUP
 #max_connections        = 100
 #table_cache            = 64
 #thread_concurrency     = 10
 #
 # * Query Cache Configuration
 #
 query_cache_limit	= 1M
 query_cache_size        = 16M
 #
 # * Logging and Replication
 #
 # Both location gets rotated by the cronjob.
 # Be aware that this log type is a performance killer.
 # As of 5.1 you can enable the log at runtime!
 #general_log_file        = /var/log/mysql/mysql.log
 #general_log             = 1
 #
 # Error log - should be very few entries.
 #
 log_error = /var/log/mysql/error.log
 #
 # Here you can see queries with especially long duration
 #log_slow_queries	= /var/log/mysql/mysql-slow.log
 #long_query_time = 2
 #log-queries-not-using-indexes
 #
 # The following can be used as easy to replay backup logs or for replication.
 # note: if you are setting up a replication slave, see README.Debian about
 #       other settings you may need to change.
 #server-id		= 1
 #log_bin			= /var/log/mysql/mysql-bin.log
 expire_logs_days	= 10
 max_binlog_size   = 100M
 #binlog_do_db		= include_database_name
 #binlog_ignore_db	= include_database_name
 #
 # * InnoDB
 #
 # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
 # Read the manual for more InnoDB related options. There are many!
 #
 # * Security Features
 #
 # Read the manual, too, if you want chroot!
 # chroot = /var/lib/mysql/
 #
 # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
 #
 # ssl-ca=/etc/mysql/cacert.pem
 # ssl-cert=/etc/mysql/server-cert.pem
 # ssl-key=/etc/mysql/server-key.pem
 
データはここだ
 datadir		= /var/lib/mysql

mysqldのベースディレクトリはここ
 basedir		= /usr

ちなみにmysqldの所在はここ
 ~$ which mysqld
 /usr/sbin/mysqld

* ''次は'' [#o8c59d82]
-php のインストール[[installing php on ubuntu desktop 16.04.1]]へ
-php のインストール[[installing php on ubuntu desktop 16.04.4]]へ

トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS