#author("2018-10-14T22:40:02+09:00","","") #author("2018-10-14T22:40:50+09:00","","") #nofollow #norelated 総数:&counter(total); 今日:&counter(today); 昨日:&counter(yesterday); * もくじ [#kd653dec] #contents *mysql-server パッケージのインストール [#lc5046af] ~$ sudo apt -y install mysql-server パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています 状態情報を読み取っています... 完了 以下の追加パッケージがインストールされます: libaio1 libevent-core-2.1-6 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.1-6 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 個、保留: 193 個。 20.4 MB のアーカイブを取得する必要があります。 この操作後に追加で 160 MB のディスク容量が消費されます。 取得:1 http://jp.archive.ubuntu.com/ubuntu bionic/main amd64 mysql-common all 5.8+1.0.4 [7,308 B] 取得:2 http://jp.archive.ubuntu.com/ubuntu bionic/main amd64 libaio1 amd64 0.3.110-5 [6,448 B] 取得:3 http://jp.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-client-core-5.7 amd64 5.7.23-0ubuntu0.18.04.1 [6,985 kB] 取得:4 http://jp.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-client-5.7 amd64 5.7.23-0ubuntu0.18.04.1 [2,312 kB] 取得:5 http://jp.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server-core-5.7 amd64 5.7.23-0ubuntu0.18.04.1 [7,777 kB] 取得:6 http://jp.archive.ubuntu.com/ubuntu bionic/main amd64 libevent-core-2.1-6 amd64 2.1.8-stable-4build1 [85.9 kB] 取得:7 http://jp.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server-5.7 amd64 5.7.23-0ubuntu0.18.04.1 [3,194 kB] 取得:8 http://jp.archive.ubuntu.com/ubuntu bionic/main amd64 libhtml-template-perl all 2.97-1 [59.0 kB] 取得:9 http://jp.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server all 5.7.23-0ubuntu0.18.04.1 [9,940 B] 20.4 MB を 1秒 で取得しました (33.3 MB/s) パッケージを事前設定しています ... 以前に未選択のパッケージ mysql-common を選択しています。 (データベースを読み込んでいます ... 現在 145658 個のファイルとディレクトリがインストールされています。) .../0-mysql-common_5.8+1.0.4_all.deb を展開する準備をしています ... mysql-common (5.8+1.0.4) を展開しています... 以前に未選択のパッケージ libaio1:amd64 を選択しています。 .../1-libaio1_0.3.110-5_amd64.deb を展開する準備をしています ... libaio1:amd64 (0.3.110-5) を展開しています... 以前に未選択のパッケージ mysql-client-core-5.7 を選択しています。 .../2-mysql-client-core-5.7_5.7.23-0ubuntu0.18.04.1_amd64.deb を展開する準備をしています ... mysql-client-core-5.7 (5.7.23-0ubuntu0.18.04.1) を展開しています... 以前に未選択のパッケージ mysql-client-5.7 を選択しています。 .../3-mysql-client-5.7_5.7.23-0ubuntu0.18.04.1_amd64.deb を展開する準備をしています ... mysql-client-5.7 (5.7.23-0ubuntu0.18.04.1) を展開しています... 以前に未選択のパッケージ mysql-server-core-5.7 を選択しています。 .../4-mysql-server-core-5.7_5.7.23-0ubuntu0.18.04.1_amd64.deb を展開する準備をしています ... mysql-server-core-5.7 (5.7.23-0ubuntu0.18.04.1) を展開しています... 以前に未選択のパッケージ libevent-core-2.1-6:amd64 を選択しています。 .../5-libevent-core-2.1-6_2.1.8-stable-4build1_amd64.deb を展開する準備をしています ... libevent-core-2.1-6:amd64 (2.1.8-stable-4build1) を展開しています... mysql-common (5.8+1.0.4) を設定しています ... update-alternatives: /etc/mysql/my.cnf (my.cnf) を提供するために自動モードで /etc/mysql/my.cnf.fallback を使います 以前に未選択のパッケージ mysql-server-5.7 を選択しています。 (データベースを読み込んでいます ... 現在 145826 個のファイルとディレクトリがインストールされています。) .../mysql-server-5.7_5.7.23-0ubuntu0.18.04.1_amd64.deb を展開する準備をしています ... mysql-server-5.7 (5.7.23-0ubuntu0.18.04.1) を展開しています... 以前に未選択のパッケージ libhtml-template-perl を選択しています。 .../libhtml-template-perl_2.97-1_all.deb を展開する準備をしています ... libhtml-template-perl (2.97-1) を展開しています... 以前に未選択のパッケージ mysql-server を選択しています。 .../mysql-server_5.7.23-0ubuntu0.18.04.1_all.deb を展開する準備をしています ... mysql-server (5.7.23-0ubuntu0.18.04.1) を展開しています... libevent-core-2.1-6:amd64 (2.1.8-stable-4build1) を設定しています ... libhtml-template-perl (2.97-1) を設定しています ... ureadahead (0.100.0-20) のトリガを処理しています ... ureadahead will be reprofiled on next reboot libc-bin (2.27-3ubuntu1) のトリガを処理しています ... libaio1:amd64 (0.3.110-5) を設定しています ... systemd (237-3ubuntu10.3) のトリガを処理しています ... man-db (2.8.3-2) のトリガを処理しています ... mysql-client-core-5.7 (5.7.23-0ubuntu0.18.04.1) を設定しています ... mysql-server-core-5.7 (5.7.23-0ubuntu0.18.04.1) を設定しています ... mysql-client-5.7 (5.7.23-0ubuntu0.18.04.1) を設定しています ... mysql-server-5.7 (5.7.23-0ubuntu0.18.04.1) を設定しています ... update-alternatives: /etc/mysql/my.cnf (my.cnf) を提供するために自動モードで /etc/mysql/mysql.cnf を使います Renaming removed key_buffer and myisam-recover options (if present) Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service. mysql-server (5.7.23-0ubuntu0.18.04.1) を設定しています ... libc-bin (2.27-3ubuntu1) のトリガを処理しています ... ureadahead (0.100.0-20) のトリガを処理しています ... systemd (237-3ubuntu10.3) のトリガを処理しています ... *mysql-client パッケージのインストール [#o70535e2] ~$ sudo apt -y install mysql-client *バージョン確認する。 [#n9661655] ~$ mysql --version mysql Ver 14.14 Distrib 5.7.23, for Linux (x86_64) using EditLine wrapper 5.7.23 だ。 *php-mysql パッケージのインストール [#g795ed04] ~$ sudo apt -y install php-mysql パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています 状態情報を読み取っています... 完了 php-mysql はすでに最新バージョン (1:7.2+60ubuntu1) です。 アップグレード: 0 個、新規インストール: 0 個、削除: 0 個、保留: 193 個。 -バージョン確認する。 ~$ dpkg -l | grep -i php-mysql ii php-mysql 1:7.2+60ubuntu1 all MySQL module for PHP [default] *MySQL環境のセキュア化 [#jc432a8a] 参考URL https://linuxconfig.org/install-mysql-on-ubuntu-18-04-bionic-beaver-linux 参考URL http://www.cyberciti.biz/faq/howto-install-mysql-on-ubuntu-linux-16-04/ 参考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 [#s9123297] 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 [#ab6d6d0a] **How do I use MySQL server? [#f4282531] 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? [#x3370759] 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? [#q1be9d0b] $ sudo systemctl start mysql **How do I stop MySQL server? [#beedb658] $ sudo systemctl stop mysql **How do I restart MySQL server? [#wfe2694d] $ sudo systemctl restart mysql **How do I find out if MySQL running/active? [#g6cb7f95] $ 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? [#m9514371] $ sudo dpkg-reconfigure mysql-server-5.7 **A note about MySQL server configuration [#n00c4adc] 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 **データベース ディレクトリ構造の生成 [#k58e7bfa] 参考URL https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html ***mysqld設定ファイルをみてデータの所在を知る [#ue295c7e] ~$ 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_open_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 #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 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 * ''次は'' [#q8c9ceb9] -php のインストール[[installing php on ubuntu desktop 18.04.1]]へ