title: /usr/bin/mysql_secure_installation and mysql_install_db do not work and cannot install mysql successfully on VPS
body: <p>PROBLEM SUMMARY</p>
  <p>Cannot successfully run three scripts that are supposed to install</p>
  <p>mysql.</p>
  <p>DETAILS about MY goal</p>
  <p>I am setting up a virtual private server that requires mysql</p>
  <p>as one of it's components.  Without this part of the installation</p>
  <p>I cannot complete the server setup.</p>
  <p>DESCRIPTION OF EXPECTED RESULTS</p>
  <p>The expected results are to have no errors in executing the</p>
  <p>mysql installation scripts.</p>
  <p>DESCRIPTION OF ACTUAL RESULTS</p>
  <p>The actual results were failed installation scripts and no</p>
  <p>successful mysql installation.</p>
  <p>ERROR MESSAGES (3)</p>
  <p>1 - <code>mysql_install_db</code>          //attempted command line execution</p>
  <p>ERROR OUTPUT UPON EXECUTION</p>
  <blockquote>
  <p>2020-08-23 15:04:20 [WARNING] mysql_install_db is deprecated.</p>
  <p>Please consider switching to mysqld --initialize</p>
  <p>2020-08-23 15:04:20 [ERROR]   The data directory needs to be
  specified</p>
  </blockquote>
  <p>2 - <code>mysqld --initialize</code>   //attempted command line execution</p>
  <p>ERROR OUTPUT UPON EXECUTION</p>
  <blockquote>
  <p>2020-08-23T15:08:05.159534Z 0 [Warning] TIMESTAMP with implicit
  DEFAULT value is deprecated. Please use
  --explicit_defaults_for_timestamp server option (see documentation for more details).</p>
  <p>2020-08-23T15:08:05.161539Z 0 [ERROR] Can't change data directory
  owner to mysql</p>
  <p>2020-08-23T15:08:05.161731Z 0 [ERROR] Aborting</p>
  </blockquote>
  <p>3 - <code>mysql_secure_installation</code>     //attempted command line execution</p>
  <p>ERROR OUTPUT UPON EXECUTION</p>
  <blockquote>
  <p>Securing the MySQL server deployment.</p>
  <p>Connecting to MySQL using a blank password.</p>
  <p>The 'validate_password' plugin is installed on the server.</p>
  <p>The subsequent steps will run with the existing configuration</p>
  <p>of the plugin.</p>
  <p>Please set the password for root here.</p>
  <p>New password:</p>
  <p>Re-enter new password:</p>
  <p>Estimated strength of the password: 50</p>
  <p>Do you wish to continue with the password provided?(Press y|Y for
  Yes, any other key for No) :</p>
  <p>Do you wish to continue with the password provided?(Press y|Y for
  Yes, any other key for No) : Y</p>
  <p>... Failed! Error: File './mysql/user.MYD' not found (Errcode: 2 - No
  such file or directory)</p>
  </blockquote>
  <p>DESCRIPTION OF WHAT I HAVE TRIED</p>
  <p>Internet search for the error messages.</p>
  <p>One post I tried was to address this error message from</p>
  <p>mysql_secure_installation command</p>
  <p>Failed! Error: File './mysql/user.MYD' not found (Errcode: 2 - No such file or directory)</p>
  <p>I found a post on Stack Overflow</p>
  <p><a href="https://stackoverflow.com/questions/54293033/trying-to-update-root-password-on-mysql-or-create-a-new-user-is-giving-me-mysql">Trying to update root password on mysql or create a new user is giving me /mysql/user.MYD error</a></p>
  <p>that suggested the following:</p>
  <p>Initializing the database.</p>
  <p>&quot;Your error means, that the table in which users are stored doesn't exist.&quot;</p>
  <p>&quot;Have a look in your /etc/my.cnf file. There should be an entry datadir. Make sure this directory is empty. Then do&quot;</p>
  <h1>mysql_install_db --defaults-file=/etc/my.cnf</h1>
  <p>This creates the schema mysql and all necessary tables. After that you
  can do</p>
  <h1><code>mysql_secure_installation</code></h1>
  <p>What I did;  I went in to look for the my.cnf file however it did not</p>
  <p>contain the datadir entry.  So I was unable to solve the problem this way.</p>
  <p>I also tried uninstalling and reinstalling mysql, mysql_server and mysqldb</p>
  <p>but this did not solve the prolem of installing these three packages.</p>
  <p>I also went to look at the error log.</p>
  <p>here is the output of <em><strong>/var/log/mysql/error.log</strong></em></p>
  <p>Skipping generation of SSL certificates as certificate files are present in data directory.</p>
  <p>2020-08-23T06:36:08.632239Z 0 [Warning] CA certificate ca.pem is self signed.</p>
  <p>2020-08-23T06:36:08.632279Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.</p>
  <p>2020-08-23T06:36:08.632376Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306</p>
  <p>2020-08-23T06:36:08.632394Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';</p>
  <p>2020-08-23T06:36:08.632431Z 0 [Note] Server socket created on IP: '127.0.0.1'.</p>
  <p>2020-08-23T06:36:08.641055Z 0 [Note] Event Scheduler: Loaded 0 events</p>
  <p>2020-08-23T06:36:08.641268Z 0 [Note] /usr/sbin/mysqld: ready for connections.</p>
  <p>Version: '5.7.31-0ubuntu0.18.04.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)</p>
  <p>2020-08-23T07:06:36.289591Z 3 [Note] <strong>Aborted connection 3 to db: 'unconnected' user: 'root' host: 'localhost' (Got an error reading communication packets)</strong></p>
  <p>2020-08-23T07:24:05.775887Z 5 [Note] <strong>Aborted connection 5 to db: 'unconnected' user: 'root' host: 'localhost' (Got an error reading communication packets)</strong></p>
  <p>2020-08-23T07:25:39.186516Z 7 [Note] <strong>Aborted connection 7 to db: 'unconnected' user: 'root' host: 'localhost' (Got an error reading communication packets)</strong></p>
  <p>2020-08-23T07:33:24.873983Z 9 [Note] Aborted connection 9 to db: 'unconnected' user: 'root' host: 'localhost' (Got an error reading communication packets)</p>
  <p>2020-08-23T07:37:04.250153Z 12 [Note] Aborted connection 12 to db: 'unconnected' user: 'root' host: 'localhost' (Got an error reading communication packets)</p>
  <p>2020-08-23T07:39:48.755869Z 14 [Note] Aborted connection 14 to db: 'unconnected' user: 'root' host: 'localhost' (Got an error reading communic</p>
  <p>and</p>
  <p>Starting shutdown...</p>
  <p>2020-08-23T15:15:51.553016Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool</p>
  <p>2020-08-23T15:15:51.553114Z 0 [ERROR] InnoDB: <strong>Cannot open '/var/lib/mysql/ib_buffer_pool.incomplete' for writing: Permission denied</strong></p>
  <p>2020-08-23T15:15:52.892146Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2720753</p>
  <p>2020-08-23T15:15:52.892240Z 0 [Note] Shutting down plugin 'MEMORY'</p>
  <p>2020-08-23T15:15:52.892253Z 0 [Note] Shutting down plugin 'CSV'</p>
  <p>2020-08-23T15:15:52.892261Z 0 [Note] Shutting down plugin 'sha256_password'</p>
  <p>2020-08-23T15:15:52.892267Z 0 [Note] Shutting down plugin 'mysql_native_password'</p>
  <p>2020-08-23T15:15:52.892567Z 0 [Note] Shutting down plugin 'binlog'</p>
  <p>2020-08-23T15:15:52.893075Z 0 [Note] /usr/sbin/mysqld: Shutdown complete</p>