<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arisa Shinozuka</title>
    <description>The latest articles on DEV Community by Arisa Shinozuka (@4risa5).</description>
    <link>https://dev.to/4risa5</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F952057%2Fd7627ca4-75bb-44ab-b95e-35fda177224c.jpeg</url>
      <title>DEV Community: Arisa Shinozuka</title>
      <link>https://dev.to/4risa5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/4risa5"/>
    <language>en</language>
    <item>
      <title>Troubleshooting: Install MySQL with brew</title>
      <dc:creator>Arisa Shinozuka</dc:creator>
      <pubDate>Sun, 18 Feb 2024 08:46:54 +0000</pubDate>
      <link>https://dev.to/4risa5/troubleshooting-install-mysql-with-brew-108o</link>
      <guid>https://dev.to/4risa5/troubleshooting-install-mysql-with-brew-108o</guid>
      <description>&lt;p&gt;I failed to install MySQL with brew again and again. But it wasn't true. I just thought so.&lt;/p&gt;

&lt;h2&gt;
  
  
  Way to my mistake
&lt;/h2&gt;

&lt;p&gt;After installing MySQL with brew command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;brew install mysql&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then, my terminal said I finished to install MySQL and need to configure the password for my root user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;We&lt;span class="s1"&gt;'ve installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -u root

To restart mysql after an upgrade:
  brew services restart mysql
Or, if you don'&lt;/span&gt;t want/need a background service you can just run:
  /opt/homebrew/opt/mysql/bin/mysqld_safe &lt;span class="nt"&gt;--datadir&lt;/span&gt;&lt;span class="se"&gt;\=&lt;/span&gt;/opt/homebrew/var/mysql
&lt;span class="o"&gt;==&amp;gt;&lt;/span&gt; Summary
🍺  /opt/homebrew/Cellar/mysql/8.3.0: 323 files, 309.4MB
&lt;span class="o"&gt;==&amp;gt;&lt;/span&gt; Running &lt;span class="sb"&gt;`&lt;/span&gt;brew cleanup mysql&lt;span class="sb"&gt;`&lt;/span&gt;...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS &lt;span class="o"&gt;(&lt;/span&gt;see &lt;span class="sb"&gt;`&lt;/span&gt;man brew&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So I tried the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;╰─➤  mysql_secure_installation                                                                                                   

Securing the MySQL server deployment.

Enter password for user root: 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I thought the &lt;code&gt;mysql_secure_installation&lt;/code&gt; requires the existing password, I thought. I had no idea about my "existing password" because I had not set up before (I have just installed as following the instruction). &lt;/p&gt;

&lt;p&gt;But this, the existence of my password, is wrong idea. What it requires here is the new password for the root user. So what I should do is just type your new password for the root user.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I did (but not necessary)
&lt;/h2&gt;

&lt;p&gt;I did not notice the fact...&lt;/p&gt;

&lt;p&gt;So I execute the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew uninstall mysql
sudo rm /opt/homebrew/etc/my.conf
sudo rm -r /opt/homebrew/var/mysql
brew install mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I tried to uninstall the mysql, delete configuration file, i.e.  '/opt/homebrew/etc/my.cnf', and caches from &lt;code&gt;/opt/homebrew/var/mysql/&lt;/code&gt;, then reinstall mysql again.&lt;/p&gt;

&lt;p&gt;Then run &lt;code&gt;mysql_secure_installation&lt;/code&gt; again, then I have got the same "issue"...&lt;/p&gt;

&lt;h2&gt;
  
  
  How to fix
&lt;/h2&gt;

&lt;p&gt;I realised my mistake after researching and reading the following article:&lt;br&gt;
&lt;a href="https://dev.to/manikbajaj/how-to-install-mysql-8-on-macos-using-homebrew-399d"&gt;https://dev.to/manikbajaj/how-to-install-mysql-8-on-macos-using-homebrew-399d&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;then I finally and successfully set up my password as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;╰─➤  mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to &lt;span class="nb"&gt;test &lt;/span&gt;passwords
and improve security. It checks the strength of password
and allows the &lt;span class="nb"&gt;users &lt;/span&gt;to &lt;span class="nb"&gt;set &lt;/span&gt;only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y &lt;span class="k"&gt;for &lt;/span&gt;Yes, any other key &lt;span class="k"&gt;for &lt;/span&gt;No: y

There are three levels of password validation policy:

LOW    Length &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; 8
MEDIUM Length &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; 8, numeric, mixed &lt;span class="k"&gt;case&lt;/span&gt;, and special characters
STRONG Length &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; 8, numeric, mixed &lt;span class="k"&gt;case&lt;/span&gt;, special characters and dictionary                  file

Please enter 0 &lt;span class="o"&gt;=&lt;/span&gt; LOW, 1 &lt;span class="o"&gt;=&lt;/span&gt; MEDIUM and 2 &lt;span class="o"&gt;=&lt;/span&gt; STRONG: 1
Please &lt;span class="nb"&gt;set &lt;/span&gt;the password &lt;span class="k"&gt;for &lt;/span&gt;root here.

New password: 

Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to &lt;span class="k"&gt;continue &lt;/span&gt;with the password provided?&lt;span class="o"&gt;(&lt;/span&gt;Press y|Y &lt;span class="k"&gt;for &lt;/span&gt;Yes, any other key &lt;span class="k"&gt;for &lt;/span&gt;No&lt;span class="p"&gt;)&lt;/span&gt; : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created &lt;span class="k"&gt;for &lt;/span&gt;them. This is intended only &lt;span class="k"&gt;for
&lt;/span&gt;testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous &lt;span class="nb"&gt;users&lt;/span&gt;? &lt;span class="o"&gt;(&lt;/span&gt;Press y|Y &lt;span class="k"&gt;for &lt;/span&gt;Yes, any other key &lt;span class="k"&gt;for &lt;/span&gt;No&lt;span class="o"&gt;)&lt;/span&gt; : y
Success.


Normally, root should only be allowed to connect from
&lt;span class="s1"&gt;'localhost'&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? &lt;span class="o"&gt;(&lt;/span&gt;Press y|Y &lt;span class="k"&gt;for &lt;/span&gt;Yes, any other key &lt;span class="k"&gt;for &lt;/span&gt;No&lt;span class="o"&gt;)&lt;/span&gt; : y
Success.

By default, MySQL comes with a database named &lt;span class="s1"&gt;'test'&lt;/span&gt; that
anyone can access. This is also intended only &lt;span class="k"&gt;for &lt;/span&gt;testing,
and should be removed before moving into a production
environment.


Remove &lt;span class="nb"&gt;test &lt;/span&gt;database and access to it? &lt;span class="o"&gt;(&lt;/span&gt;Press y|Y &lt;span class="k"&gt;for &lt;/span&gt;Yes, any other key &lt;span class="k"&gt;for &lt;/span&gt;No&lt;span class="o"&gt;)&lt;/span&gt; : y
 - Dropping &lt;span class="nb"&gt;test &lt;/span&gt;database...
Success.

 - Removing privileges on &lt;span class="nb"&gt;test &lt;/span&gt;database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? &lt;span class="o"&gt;(&lt;/span&gt;Press y|Y &lt;span class="k"&gt;for &lt;/span&gt;Yes, any other key &lt;span class="k"&gt;for &lt;/span&gt;No&lt;span class="o"&gt;)&lt;/span&gt; : y
Success.

All &lt;span class="k"&gt;done&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Phew!&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>macos</category>
      <category>homebrew</category>
    </item>
    <item>
      <title>Demystifying Data Persistence: Where Docker Stores Your MySQL data?</title>
      <dc:creator>Arisa Shinozuka</dc:creator>
      <pubDate>Sat, 17 Feb 2024 08:37:20 +0000</pubDate>
      <link>https://dev.to/4risa5/demystifying-data-persistence-where-docker-stores-your-mysql-data-3f8e</link>
      <guid>https://dev.to/4risa5/demystifying-data-persistence-where-docker-stores-your-mysql-data-3f8e</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;The cover image by &lt;a href="https://unsplash.com/@carrier_lost?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash"&gt;Ian Taylor&lt;/a&gt; on &lt;a href="https://unsplash.com/photos/red-and-blue-cargo-ship-on-sea-during-daytime-HjBOmBPbi9k?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Can we persistence data on the database when running it on Docker? The answer is absolutely yes. Except this function, Docker cannot be used widely as currently used.&lt;/p&gt;

&lt;p&gt;But where is the data saved? Or precisely, when/where we configure the location of the saved data?&lt;/p&gt;

&lt;p&gt;Short answer is: we can specify the location when we create a container for a database, with &lt;code&gt;-v&lt;/code&gt; option. &lt;/p&gt;

&lt;p&gt;I'd like to note that the location of the volume is in the container, not in your host system like Mac or Windows system. I misunderstood there is the data in a directory under my Mac system (that's why I write this article not to forget this fact). I hope you won't waste your time as I did!&lt;/p&gt;

&lt;p&gt;The following is the recap of &lt;code&gt;docker run&lt;/code&gt; command to create a container.&lt;br&gt;
When create a container, you will use, for example, the following command to run a MySQL container in Docker, after you pull the image for the database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; 
&lt;span class="nt"&gt;--name&lt;/span&gt; my-mysql-db 
&lt;span class="nt"&gt;-p&lt;/span&gt; 3306:3306 
&lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;MYSQL_ROOT_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your_password
&lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;MYSQL_DATABASE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your_database_name
&lt;span class="nt"&gt;-v&lt;/span&gt; mysql-data:/var/lib/mysql 
mysql:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;options used in the &lt;code&gt;docker run&lt;/code&gt; above&lt;/th&gt;
&lt;th&gt;meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-d&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;in detached mode: the container run in the background&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--name my-sql-db&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;assigns a custom name to the container (it's named "my-sql-db")&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-p 3306:3306&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;maps the container's port 3306 (the default MySQL port) to port 3306 on your host system&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-e MYSQL_ROOT_PASSWORD=your_password&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;sets an environment variable named &lt;code&gt;MYSQL_ROOT_PASSWORD&lt;/code&gt; within the container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-v mysql-data:/var/lib/mysql&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;defines a volume mapping: it creates a named volume called &lt;code&gt;mysql-data&lt;/code&gt; on your host system, which is mounted at the path &lt;code&gt;/var/lib/mysql&lt;/code&gt; inside the container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;mysql:latest&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;specifies the Docker image to use&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>mysql</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
