総数:14 今日:1 昨日:0
~$ 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 --version mysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper5.7.22 だ。
~$ 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 個、保留: 4 個。 959 kB のアーカイブを取得する必要があります。 この操作後に追加で 5,206 kB のディスク容量が消費されます。 取得:1 http://jp.archive.ubuntu.com/ubuntu xenial/main amd64 php-common all 1:35ubuntu6 [10.8 kB] 取得:2 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php7.0-common amd64 7.0.8-0ubuntu0.16.04.3 [822 kB] 取得:3 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php7.0-mysql amd64 7.0.8-0ubuntu0.16.04.3 [124 kB] 取得:4 http://jp.archive.ubuntu.com/ubuntu xenial/main amd64 php-mysql all 1:7.0+35ubuntu6 [1,936 B] 959 kB を 0秒 で取得しました (3,875 kB/s) 以前に未選択のパッケージ php-common を選択しています。 (データベースを読み込んでいます ... 現在 184655 個のファイルとディレクトリがインストールされています。) .../php-common_1%3a35ubuntu6_all.deb を展開する準備をしています ... php-common (1:35ubuntu6) を展開しています... 以前に未選択のパッケージ php7.0-common を選択しています。 .../php7.0-common_7.0.8-0ubuntu0.16.04.3_amd64.deb を展開する準備をしています ... php7.0-common (7.0.8-0ubuntu0.16.04.3) を展開しています... 以前に未選択のパッケージ php7.0-mysql を選択しています。 .../php7.0-mysql_7.0.8-0ubuntu0.16.04.3_amd64.deb を展開する準備をしています ... php7.0-mysql (7.0.8-0ubuntu0.16.04.3) を展開しています... 以前に未選択のパッケージ php-mysql を選択しています。 .../php-mysql_1%3a7.0+35ubuntu6_all.deb を展開する準備をしています ... php-mysql (1:7.0+35ubuntu6) を展開しています... php-common (1:35ubuntu6) を設定しています ... php7.0-common (7.0.8-0ubuntu0.16.04.3) を設定しています ... 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.8-0ubuntu0.16.04.3) を設定しています ... 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) を設定しています ...
~$ dpkg -l | grep -i php-mysql ii php-mysql 1:7.0+35ubuntu6 all MySQL module for PHP [default]
~$ sudo apt-get -y install mysql-client
パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています 状態情報を読み取っています... 完了 以下のパッケージが新たにインストールされます: mysql-client アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 4 個。 10.0 kB のアーカイブを取得する必要があります。 この操作後に追加で 132 kB のディスク容量が消費されます。 取得:1 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-client all 5.7.15-0ubuntu0.16.04.1 [10.0 kB] 10.0 kB を 0秒 で取得しました (113 kB/s) 以前に未選択のパッケージ mysql-client を選択しています。 (データベースを読み込んでいます ... 現在 184745 個のファイルとディレクトリがインストールされています。) .../mysql-client_5.7.15-0ubuntu0.16.04.1_all.deb を展開する準備をしています ... mysql-client (5.7.15-0ubuntu0.16.04.1) を展開しています... mysql-client (5.7.15-0ubuntu0.16.04.1) を設定しています ...
参考URL http://www.cyberciti.biz/faq/howto-install-mysql-on-ubuntu-linux-16-04/
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!
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 5 Server version: 5.7.15-0ubuntu0.16.04.1 (Ubuntu) Copyright (c) 2000, 2016, 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>
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>
$ sudo systemctl start mysql
$ sudo systemctl stop mysql
$ sudo systemctl restart mysql
$ sudo systemctl status mysql.service
$ sudo dpkg-reconfigure mysql-server-5.7
You may edit the /etc/mysql/my.cnf file to configure the basic settings
such as TCP/IP port, IP address binding, and other options.
However, The MySQL database server configuration file on the Ubuntu 16.04 LTS is
located at
/etc/mysql/mysql.conf.d/mysqld.cnf
and one can edit using a text editor such as gvim:
$ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf $ sudo systemctl restart mysql.service
参考URL https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html
~$ cat /etc/mysql/mysql.conf.d/mysqld.cnf
一部抜粋
[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
データはここだ
datadir = /var/lib/mysql
mysqldのベースディレクトリはここ
basedir = /usr
ちなみにmysqldの所在はここ
~$ which mysqld /usr/sbin/mysqld