#author("2021-02-12T13:53:32+09:00","","")
#author("2021-02-12T13:58:18+09:00","","")
#nofollow
#norelated
総数:&counter(total); 今日:&counter(today); 昨日:&counter(yesterday);

* もくじ [#u3ad1893]

#contents

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

 パッケージリストを読み込んでいます... 完了
 依存関係ツリーを作成しています                
 状態情報を読み取っています... 完了
 以下の追加パッケージがインストールされます:
   libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-perl libhtml-template-perl libmecab2 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0
   mysql-client-core-8.0 mysql-server-8.0 mysql-server-core-8.0
 提案パッケージ:
   libipc-sharedcache-perl mailx tinyca
 以下のパッケージが新たにインストールされます:
   libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-perl libhtml-template-perl libmecab2 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0
   mysql-client-core-8.0 mysql-server mysql-server-8.0 mysql-server-core-8.0
 アップグレード: 0 個、新規インストール: 15 個、削除: 0 個、保留: 0 個。
 30.6 MB のアーカイブを取得する必要があります。
 この操作後に追加で 249 MB のディスク容量が消費されます。
 取得:1 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 mysql-client-core-8.0 amd64 8.0.23-0ubuntu0.20.04.1 [4,215 kB]
 取得:2 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 mysql-client-8.0 amd64 8.0.23-0ubuntu0.20.04.1 [22.0 kB]
 取得:3 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libevent-core-2.1-7 amd64 2.1.11-stable-1 [89.1 kB]
 取得:4 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libevent-pthreads-2.1-7 amd64 2.1.11-stable-1 [7,372 B]
 取得:5 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libmecab2 amd64 0.996-10build1 [233 kB]
 取得:6 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 mysql-server-core-8.0 amd64 8.0.23-0ubuntu0.20.04.1 [17.7 MB]
 取得:7 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 mysql-server-8.0 amd64 8.0.23-0ubuntu0.20.04.1 [1,275 kB]
 取得:8 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libcgi-pm-perl all 4.46-1 [186 kB]
 取得:9 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libfcgi-perl amd64 0.79-1 [33.1 kB]
 取得:10 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libcgi-fast-perl all 1:2.15-1 [10.5 kB]
 取得:11 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libhtml-template-perl all 2.97-1 [59.0 kB]
 取得:12 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 mecab-utils amd64 0.996-10build1 [4,912 B]
 取得:13 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 mecab-ipadic all 2.7.0-20070801+main-2.1 [6,714 kB]
 取得:14 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 mecab-ipadic-utf8 all 2.7.0-20070801+main-2.1 [4,380 B]
 取得:15 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 mysql-server all 8.0.23-0ubuntu0.20.04.1 [9,548 B]
 30.6 MB を 6秒 で取得しました (5,164 kB/s)     
 パッケージを事前設定しています ...
 以前に未選択のパッケージ mysql-client-core-8.0 を選択しています。
 (データベースを読み込んでいます ... 現在 197096 個のファイルとディレクトリがインストールされています。)
 .../00-mysql-client-core-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb を展開する準備をしています ...
 mysql-client-core-8.0 (8.0.23-0ubuntu0.20.04.1) を展開しています...
 以前に未選択のパッケージ mysql-client-8.0 を選択しています。
 .../01-mysql-client-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb を展開する準備をしています ...
 mysql-client-8.0 (8.0.23-0ubuntu0.20.04.1) を展開しています...
 以前に未選択のパッケージ libevent-core-2.1-7:amd64 を選択しています。
 .../02-libevent-core-2.1-7_2.1.11-stable-1_amd64.deb を展開する準備をしています ...
 libevent-core-2.1-7:amd64 (2.1.11-stable-1) を展開しています...
 以前に未選択のパッケージ libevent-pthreads-2.1-7:amd64 を選択しています。
 .../03-libevent-pthreads-2.1-7_2.1.11-stable-1_amd64.deb を展開する準備をしています ...
 libevent-pthreads-2.1-7:amd64 (2.1.11-stable-1) を展開しています...
 以前に未選択のパッケージ libmecab2:amd64 を選択しています。
 .../04-libmecab2_0.996-10build1_amd64.deb を展開する準備をしています ...
 libmecab2:amd64 (0.996-10build1) を展開しています...
 以前に未選択のパッケージ mysql-server-core-8.0 を選択しています。
 .../05-mysql-server-core-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb を展開する準備をしています ...
 mysql-server-core-8.0 (8.0.23-0ubuntu0.20.04.1) を展開しています...
 以前に未選択のパッケージ mysql-server-8.0 を選択しています。
 .../06-mysql-server-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb を展開する準備をしています ...
 mysql-server-8.0 (8.0.23-0ubuntu0.20.04.1) を展開しています...
 以前に未選択のパッケージ libcgi-pm-perl を選択しています。
 .../07-libcgi-pm-perl_4.46-1_all.deb を展開する準備をしています ...
 libcgi-pm-perl (4.46-1) を展開しています...
 以前に未選択のパッケージ libfcgi-perl を選択しています。
 .../08-libfcgi-perl_0.79-1_amd64.deb を展開する準備をしています ...
 libfcgi-perl (0.79-1) を展開しています...
 以前に未選択のパッケージ libcgi-fast-perl を選択しています。
 .../09-libcgi-fast-perl_1%3a2.15-1_all.deb を展開する準備をしています ...
 libcgi-fast-perl (1:2.15-1) を展開しています...
 以前に未選択のパッケージ libhtml-template-perl を選択しています。
 .../10-libhtml-template-perl_2.97-1_all.deb を展開する準備をしています ...
 libhtml-template-perl (2.97-1) を展開しています...
 以前に未選択のパッケージ mecab-utils を選択しています。
 .../11-mecab-utils_0.996-10build1_amd64.deb を展開する準備をしています ...
 mecab-utils (0.996-10build1) を展開しています...
 以前に未選択のパッケージ mecab-ipadic を選択しています。
 .../12-mecab-ipadic_2.7.0-20070801+main-2.1_all.deb を展開する準備をしています ...
 mecab-ipadic (2.7.0-20070801+main-2.1) を展開しています...
 以前に未選択のパッケージ mecab-ipadic-utf8 を選択しています。
 .../13-mecab-ipadic-utf8_2.7.0-20070801+main-2.1_all.deb を展開する準備をしています ...
 mecab-ipadic-utf8 (2.7.0-20070801+main-2.1) を展開しています...
 以前に未選択のパッケージ mysql-server を選択しています。
 .../14-mysql-server_8.0.23-0ubuntu0.20.04.1_all.deb を展開する準備をしています ...
 mysql-server (8.0.23-0ubuntu0.20.04.1) を展開しています...
 libmecab2:amd64 (0.996-10build1) を設定しています ...
 mysql-client-core-8.0 (8.0.23-0ubuntu0.20.04.1) を設定しています ...
 libcgi-pm-perl (4.46-1) を設定しています ...
 libhtml-template-perl (2.97-1) を設定しています ...
 mecab-utils (0.996-10build1) を設定しています ...
 libevent-core-2.1-7:amd64 (2.1.11-stable-1) を設定しています ...
 mysql-client-8.0 (8.0.23-0ubuntu0.20.04.1) を設定しています ...
 libfcgi-perl (0.79-1) を設定しています ...
 libevent-pthreads-2.1-7:amd64 (2.1.11-stable-1) を設定しています ...
 mecab-ipadic (2.7.0-20070801+main-2.1) を設定しています ...
 Compiling IPA dictionary for Mecab.  This takes long time...
 reading /usr/share/mecab/dic/ipadic/unk.def ... 40
 emitting double-array: 100% |###########################################| 
 /usr/share/mecab/dic/ipadic/model.def is not found. skipped.
 reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032
 reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202
 reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171
 reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91
 reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393
 reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999
 reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135
 reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42
 reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668
 reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
 reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328
 reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199
 reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146
 reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328
 reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252
 reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208
 reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477
 reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120
 reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750
 reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210
 reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146
 reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151
 reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221
 reading /usr/share/mecab/dic/ipadic/Others.csv ... 2
 reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19
 reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795
 emitting double-array: 100% |###########################################| 
 reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
 emitting matrix      : 100% |###########################################| 
 
 done!
 update-alternatives: /var/lib/mecab/dic/debian (mecab-dictionary) を提供するために自動モードで /var/lib/mecab/dic/ipadic を使います
 libcgi-fast-perl (1:2.15-1) を設定しています ...
 mysql-server-core-8.0 (8.0.23-0ubuntu0.20.04.1) を設定しています ...
 mecab-ipadic-utf8 (2.7.0-20070801+main-2.1) を設定しています ...
 Compiling IPA dictionary for Mecab.  This takes long time...
 reading /usr/share/mecab/dic/ipadic/unk.def ... 40
 emitting double-array: 100% |###########################################| 
 /usr/share/mecab/dic/ipadic/model.def is not found. skipped.
 reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032
 reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202
 reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171
 reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91
 reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393
 reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999
 reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135
 reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42
 reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668
 reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
 reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328
 reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199
 reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146
 reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328
 reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252
 reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208
 reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477
 reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120
 reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750
 reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210
 reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146
 reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151
 reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221
 reading /usr/share/mecab/dic/ipadic/Others.csv ... 2
 reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19
 reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795
 emitting double-array: 100% |###########################################| 
 reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
 emitting matrix      : 100% |###########################################| 
 
 done!
 update-alternatives: /var/lib/mecab/dic/debian (mecab-dictionary) を提供するために自動モードで /var/lib/mecab/dic/ipadic-utf8 を使います
 mysql-server-8.0 (8.0.23-0ubuntu0.20.04.1) を設定しています ...
 update-alternatives: /etc/mysql/my.cnf (my.cnf) を提供するために自動モードで /etc/mysql/mysql.cnf を使います
 Renaming removed key_buffer and myisam-recover options (if present)
 mysqld will log errors to /var/log/mysql/error.log
 mysqld is running as pid 3494
 Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
 mysql-server (8.0.23-0ubuntu0.20.04.1) を設定しています ...
 systemd (245.4-4ubuntu3.4) のトリガを処理しています ...
 man-db (2.9.1-1) のトリガを処理しています ...
 libc-bin (2.31-0ubuntu9.2) のトリガを処理しています ...


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

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

*バージョン確認する。 [#qd761e6d]
 ~$ mysql --version
 mysql  Ver 8.0.23-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

8.0.23 だ。

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

 パッケージリストを読み込んでいます... 完了
 依存関係ツリーを作成しています                
 状態情報を読み取っています... 完了
 以下の追加パッケージがインストールされます:
   php-common php7.4-common php7.4-mysql
 以下のパッケージが新たにインストールされます:
   php-common php-mysql php7.4-common php7.4-mysql
 アップグレード: 0 個、新規インストール: 4 個、削除: 0 個、保留: 0 個。
 1,114 kB のアーカイブを取得する必要があります。
 この操作後に追加で 8,142 kB のディスク容量が消費されます。
 取得:1 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 php-common all 2:75 [11.9 kB]
 取得:2 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 php7.4-common amd64 7.4.3-4ubuntu2.4 [979 kB]
 取得:3 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 php7.4-mysql amd64 7.4.3-4ubuntu2.4 [121 kB]
 取得:4 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 php-mysql all 2:7.4+75 [2,000 B]
 1,114 kB を 1秒 で取得しました (1,074 kB/s)
 以前に未選択のパッケージ php-common を選択しています。
 (データベースを読み込んでいます ... 現在 197462 個のファイルとディレクトリがインストールされています。)
 .../php-common_2%3a75_all.deb を展開する準備をしています ...
 php-common (2:75) を展開しています...
 以前に未選択のパッケージ php7.4-common を選択しています。
 .../php7.4-common_7.4.3-4ubuntu2.4_amd64.deb を展開する準備をしています ...
 php7.4-common (7.4.3-4ubuntu2.4) を展開しています...
 以前に未選択のパッケージ php7.4-mysql を選択しています。
 .../php7.4-mysql_7.4.3-4ubuntu2.4_amd64.deb を展開する準備をしています ...
 php7.4-mysql (7.4.3-4ubuntu2.4) を展開しています...
 以前に未選択のパッケージ php-mysql を選択しています。
 .../php-mysql_2%3a7.4+75_all.deb を展開する準備をしています ...
 php-mysql (2:7.4+75) を展開しています...
 php-common (2:75) を設定しています ...
 Created symlink /etc/systemd/system/timers.target.wants/phpsessionclean.timer → /lib/systemd/system/phpsessionclean.timer.
 php7.4-common (7.4.3-4ubuntu2.4) を設定しています ...
 Creating config file /etc/php/7.4/mods-available/calendar.ini with new version
 Creating config file /etc/php/7.4/mods-available/ctype.ini with new version
 Creating config file /etc/php/7.4/mods-available/exif.ini with new version
 Creating config file /etc/php/7.4/mods-available/fileinfo.ini with new version
 Creating config file /etc/php/7.4/mods-available/ffi.ini with new version
 Creating config file /etc/php/7.4/mods-available/ftp.ini with new version
 Creating config file /etc/php/7.4/mods-available/gettext.ini with new version
 Creating config file /etc/php/7.4/mods-available/iconv.ini with new version
 Creating config file /etc/php/7.4/mods-available/pdo.ini with new version
 Creating config file /etc/php/7.4/mods-available/phar.ini with new version
 Creating config file /etc/php/7.4/mods-available/posix.ini with new version
 Creating config file /etc/php/7.4/mods-available/shmop.ini with new version
 Creating config file /etc/php/7.4/mods-available/sockets.ini with new version
 Creating config file /etc/php/7.4/mods-available/sysvmsg.ini with new version
 Creating config file /etc/php/7.4/mods-available/sysvsem.ini with new version
 Creating config file /etc/php/7.4/mods-available/sysvshm.ini with new version
 Creating config file /etc/php/7.4/mods-available/tokenizer.ini with new version
 php7.4-mysql (7.4.3-4ubuntu2.4) を設定しています ...
 Creating config file /etc/php/7.4/mods-available/mysqlnd.ini with new version
 Creating config file /etc/php/7.4/mods-available/mysqli.ini with new version
 Creating config file /etc/php/7.4/mods-available/pdo_mysql.ini with new version
 php-mysql (2:7.4+75) を設定しています ...

-バージョン確認する。
 ~$ dpkg -l | grep -i php-mysql
 ii  php-mysql                                  2:7.4+75                            all          MySQL module for PHP [default]


*MySQL環境のセキュア化 [#z996536e]
参考URL https://linuxconfig.org/install-mysql-on-ubuntu-18-04-bionic-beaver-linux &br;
参考URL http://www.cyberciti.biz/faq/howto-install-mysql-on-ubuntu-linux-16-04/  &br;

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

 Securing the MySQL server deployment.
 
 Connecting to MySQL using a blank password.
 
 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キーを押す。

 Please set the password for root here.
 
 New password: 
rootとしてのパスワードを入力する。例) root と入力する。

 Re-enter new password: 
再度 rootとしてのパスワードを入力する。例) root と入力する。

 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 [#n9acc7aa]
**How do I use MySQL server? [#h0f0e3a5]
To log in as the root user, type:
 $ sudo mysql -u root -p

 Enter password: 
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 7
 Server version: 5.7.23-0ubuntu0.18.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? [#g36244ec]
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:
 $ sudo mysql -u <DATABASE-USERNAME> -p <DATABASE-NAME>

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

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

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

**How do I find out if MySQL running/active? [#j9e1bb06]
 $ 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? [#q3b4eaa3]
 $ sudo dpkg-reconfigure mysql-server-5.7

**A note about MySQL server configuration [#o1912650]
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

**データベース ディレクトリ構造の生成 [#o8354695]
参考URL
https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html
***mysqld設定ファイルをみてデータの所在を知る [#uc49f5fb]
 ~$ 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
 # pid-file	= /var/run/mysqld/mysqld.pid
 # socket	= /var/run/mysqld/mysqld.sock
 # port		= 3306
 # datadir	= /var/lib/mysql
 
 
 # If MySQL is running as a replication slave, this should be
 # changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
 # tmpdir		= /tmp
 #
 # 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
 mysqlx-bind-address	= 127.0.0.1
 #
 # * Fine Tuning
 #
 key_buffer_size		= 16M
 max_allowed_packet	= 16M
 thread_stack		= 192K
 thread_cache_size       = 8
 # max_allowed_packet	= 64M
 # thread_stack		= 256K
 
 # thread_cache_size       = -1
 
 # 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_open_cache       = 64
 #thread_concurrency     = 10
 
 # max_connections        = 151
 
 # table_open_cache       = 4000
 
 #
 # * Query Cache Configuration
 #
 query_cache_limit	= 1M
 query_cache_size        = 16M
 #
 # * Logging and Replication
 #
 # Both location gets rotated by the cronjob.
 #
 # Log all queries
 # 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
 # general_log_file        = /var/log/mysql/query.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
 #slow_query_log		= 1
 #slow_query_log_file	= /var/log/mysql/mysql-slow.log
 #long_query_time = 2
 #log-queries-not-using-indexes
 # slow_query_log		= 1
 # slow_query_log_file	= /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
 # server-id		= 1
 # log_bin			= /var/log/mysql/mysql-bin.log
 # binlog_expire_logs_seconds	= 2592000
 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
 # binlog_do_db		= include_database_name
 # binlog_ignore_db	= include_database_name


 
データはここだ
 datadir		= /var/lib/mysql

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

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

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

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