{"id":3438,"date":"2019-07-20T16:18:49","date_gmt":"2019-07-20T13:18:49","guid":{"rendered":"https:\/\/kifarunix.com\/?p=3438"},"modified":"2019-07-20T16:18:50","modified_gmt":"2019-07-20T13:18:50","slug":"install-mysql-8-on-debian-10-buster","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-mysql-8-on-debian-10-buster\/","title":{"rendered":"Install MySQL 8 on Debian 10 Buster"},"content":{"rendered":"\n<p>Welcome to our tutorial on how to install MySQL 8 on Debian 10 Buster.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install MySQL 8 on Debian 10 Buster<\/h2>\n\n\n\n<p>In this guide, we are going to install MySQL 8 on Debian 10 Buster from the source code. As such, before you can continue, you need to install some required dependencies.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install Required Dependencies<\/h3>\n\n\n\n<p>Since we are installing MySQL 8 from the source code, there are a number of build tools that are required for a successful build process.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install cmake libncursesw5-dev libncurses5-dev cmake build-essential <code>libssl-dev<\/code> pkg-config<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install Boost C++ Library.<\/h4>\n\n\n\n<p>As a required dependency, MySQL currently requires boost_1_69_0. You would however install from repos, but the available version is boost_1_67. Hence, you need to build Boost C++ from source code. Therefore, download it and build it and install it as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/dl.bintray.com\/boostorg\/release\/1.69.0\/source\/boost_1_69_0.tar.gz -P \/tmp<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd \/tmp<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tar xzf boost_1_69_0.tar.gz<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd boost_1_69_0\n<code>.\/bootstrap.sh --prefix=\/us<\/code>r\/<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>.\/b2 \n.\/b2 install<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Create <code>mysql<\/code>&nbsp;User and Group<\/h3>\n\n\n\n<p>A&nbsp;<code>mysql<\/code>&nbsp;user is required to run MySQL server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>useradd -r -M -s \/bin\/false mysql<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Download MySQL 8 Source Code<\/h3>\n\n\n\n<p>Next, navigate to <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/dev.mysql.com\/downloads\/mysql\/\" target=\"_blank\">MySQL Download Area<\/a> and download the generic Linux (Architecture Independent) MySQL 8 source code. You can simply run the command below to download MySQL 8.16.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/dev.mysql.com\/get\/Downloads\/MySQL-8.0\/mysql-8.0.16.tar.gz -P \/tmp<\/code><\/pre>\n\n\n\n<p>Once the download is done, verify the integrity by comparing the MD5 checksums. The MD5 checksum of the downloaded archive should be: MD5:&nbsp;<code>06f16ed2dc84abeaa77c697c2d6f07e5<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/tmp\nmd5sum mysql-8.0.16.tar.gz \n06f16ed2dc84abeaa77c697c2d6f07e5  mysql-8.0.16.tar.gz<\/code><\/pre>\n\n\n\n<p>If the integrity of the downloaded file passes, proceed to the next step.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Extract the Source Code<\/h3>\n\n\n\n<p>Once the download is done, extract the MySQL 8 archive. In this demo, MySQL tarball is downloaded to <strong>\/tmp<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tar xzf mysql-8.0.16.tar.gz<\/code><\/pre>\n\n\n\n<p>Navigate to the extracted source directory and create MySQL 8 build directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd mysql-8.0.16\/<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mkdir build<\/code><\/pre>\n\n\n\n<p>Next, navigate to the build directory just created and build it as shown below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd build\ncmake ..\/..\/mysql-8.0.16<\/code><\/pre>\n\n\n\n<p>Next, run the&nbsp;<strong>make<\/strong>&nbsp;command to build the directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install MySQL 8 on Debian 10 Buster<\/h3>\n\n\n\n<p>Once the compilation of MySQL is done, you can install it using the <strong>make install<\/strong> command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install<\/code><\/pre>\n\n\n\n<p>This will install MySQL under <strong>\/usr\/local\/mysql<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Initialize MySQL 8 Data Directory<\/h3>\n\n\n\n<p>Once the installation is done, you need to initialize the data directory. Hence, navigate to MySQL installation directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd \/usr\/local\/mysql\/<\/code><\/pre>\n\n\n\n<p>Next, create a MySQL directory for import and export operations. This directory will be used a value to the <strong>secure_file_priv<\/strong> system variable.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mkdir mysql-files<\/code><\/pre>\n\n\n\n<p>Set the user and group ownership of the the directory above to <strong>mysql<\/strong>. Also set the permissions of the directory to <strong>rwxr-x&#8212;<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chown mysql:mysql mysql-files\nchmod 750 mysql-files<\/code><\/pre>\n\n\n\n<p>Next, initialize the database by executing the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>bin\/mysqld --initialize --user=mysql<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>2019-07-20T12:56:06.835551Z 0 [System] [MY-013169] [Server] \/usr\/local\/mysql\/bin\/mysqld (mysqld 8.0.16) initializing of server in progress as process 11174\n2019-07-20T12:56:10.680260Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: .qMkS;oEu8+(\n2019-07-20T12:56:12.782049Z 0 [System] [MY-013170] [Server] \/usr\/local\/mysql\/bin\/mysqld (mysqld 8.0.16) initializing of server has completed<\/code><\/pre>\n\n\n\n<p>As you can see from the output, the initial temporary password of the <strong>root@localhost<\/strong> user is generated, <strong>A temporary password is generated for root@localhost:<\/strong> .<strong>qMkS;oEu8+(<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Running MySQL 8<\/h3>\n\n\n\n<p>Copy MySQL startup files from the <strong>support-files<\/strong> directory to <strong>\/etc\/init.d<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cp support-files\/mysql.server \/etc\/init.d\/mysql<\/code><\/pre>\n\n\n\n<p>Reload the systemd manager configuration.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl daemon-reload<\/code><\/pre>\n\n\n\n<p>Start MySQL.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl start mysql<\/code><\/pre>\n\n\n\n<p>When mysql is run, <strong>systemd-sysv-generator<\/strong> will generate the <strong>\/run\/systemd\/generator.late\/mysql.service<\/strong> file. Copy this file to <strong>\/etc\/systemd\/system<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cp \/run\/systemd\/generator.late\/mysql.service \/etc\/systemd\/system<\/code><\/pre>\n\n\n\n<p>Edit the <strong>\/etc\/systemd\/system\/mysql.service<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>export EDITOR=vim\nsystemctl edit mysql.service<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n\n\n\n<p>Enable MySQL to run on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable mysql<\/code><\/pre>\n\n\n\n<p>Add MySQL binary path your PATH environment.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>export PATH=$PATH:\/usr\/local\/mysql\/bin\/<\/code><\/pre>\n\n\n\n<p>Verify that MySQL is working as expected by connecting to it using the temporary password generated during initialization.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql -u root -p<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter password: .qMkS;oEu8+(\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 8\nServer version: 8.0.16\n\nCopyright (c) 2000, 2019, Oracle and\/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql><\/code><\/pre>\n\n\n\n<p>Once you login, reset the root password.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyP@ssWord';<\/code><\/pre>\n\n\n\n<p>You can further confirm the version of MySQL by running the query.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>SHOW VARIABLES LIKE \"%version%\";<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>+--------------------------+-------------------------------+\n| Variable_name            | Value                         |\n+--------------------------+-------------------------------+\n| immediate_server_version | 999999                        |\n| innodb_version           | 8.0.16                        |\n| original_server_version  | 999999                        |\n| protocol_version         | 10                            |\n| slave_type_conversions   |                               |\n| tls_version              | TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 |\n| version                  | 8.0.16                        |\n| version_comment          | Source distribution           |\n| version_compile_machine  | x86_64                        |\n| version_compile_os       | Linux                         |\n| version_compile_zlib     | 1.2.11                        |\n+--------------------------+-------------------------------+\n11 rows in set (0.02 sec)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">MySQL initial Security<\/h3>\n\n\n\n<p>Next, you can run the initial security script, <strong>mysql_secure_installation<\/strong> to remove anonymous database users, disable remote root login and remove the test databases.<\/p>\n\n\n\n<p>That is all on how to install MySQL 8 on Debian 10 Buster. Enjoy.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Related Tutorials;<\/h3>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-mysql-8-on-freebsd-12\/\" target=\"_blank\">Install MySQL 8 on FreeBSD 12<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-mysql-8-on-debian-9\/\" target=\"_blank\">Install MySQL 8 on Debian 9<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mysql-8-on-fedora-30-fedora-29\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install MySQL 8 on Fedora 30\/Fedora 29<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-mariadb-10-on-debian-10-buster\/\" target=\"_blank\">Install MariaDB 10 on Debian 10 Buster<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mariadb-10-4-on-ubuntu-18-04-debian-9\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install MariaDB 10.4 on Ubuntu 18.04\/Debian 9<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to our tutorial on how to install MySQL 8 on Debian 10 Buster. Install MySQL 8 on Debian 10 Buster In this guide, we<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[299,121,929],"tags":[1000,1039,135,999],"class_list":["post-3438","post","type-post","status-publish","format-standard","hentry","category-database","category-howtos","category-mysql","tag-database","tag-debian-10-buster","tag-mysql","tag-mysql-8","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/3438"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=3438"}],"version-history":[{"count":11,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/3438\/revisions"}],"predecessor-version":[{"id":3724,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/3438\/revisions\/3724"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=3438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=3438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=3438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}