<?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: SimpleBackups</title>
    <description>The latest articles on DEV Community by SimpleBackups (@simplebackupsio).</description>
    <link>https://dev.to/simplebackupsio</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%2F122450%2Fe743f344-ab70-4db0-84a7-b2bbe2a9e028.png</url>
      <title>DEV Community: SimpleBackups</title>
      <link>https://dev.to/simplebackupsio</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/simplebackupsio"/>
    <language>en</language>
    <item>
      <title>Mini Guide: How to Import a SQL File in MySQL</title>
      <dc:creator>SimpleBackups</dc:creator>
      <pubDate>Mon, 07 Dec 2020 14:32:15 +0000</pubDate>
      <link>https://dev.to/simplebackupsio/mini-guide-how-to-import-a-sql-file-in-mysql-1n68</link>
      <guid>https://dev.to/simplebackupsio/mini-guide-how-to-import-a-sql-file-in-mysql-1n68</guid>
      <description>&lt;p&gt;Have you just begun to learn how to work with SQL files using MySQL? Maybe you feel a bit lost on how to import files with this tool. Luckily, importing and exporting files via MySQL is actually quite simple. Learn how to use MySQL to import SQL files by following the step-by-step guide below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Import a SQL file using Command Line
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open XAMPP.&lt;/li&gt;
&lt;li&gt;Launch Apache Server and MySQL Database.&lt;/li&gt;
&lt;li&gt;Create a database via phpMyAdmin.&lt;/li&gt;
&lt;li&gt;Copy the SQL file of your choice to the &lt;strong&gt;xampp/mysql/bin/&lt;/strong&gt; directory.&lt;/li&gt;
&lt;li&gt;Open &lt;strong&gt;Command Prompt.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;xampp/mysql/bin/.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Type: &lt;code&gt;mysql -u username -p database_name &amp;lt; file.sql&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;username&lt;/code&gt; refers to your MySQL username.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;database_name&lt;/code&gt; refers to the database you want to import.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;file.sql&lt;/code&gt; is your file name.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;If you've assigned a password, type it now and press Enter.&lt;/li&gt;
&lt;li&gt;Open phpMyAdmin and select your database to ensure that the tables have imported properly.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Import a SQL file using mysqldump
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;To import a .sql file with mysqldump, use the &lt;code&gt;mysqlimport&lt;/code&gt; command and use the following flags and syntax &lt;code&gt;$ mysqlimport -u magazine_admin -p magazines_production ~/backup/database/magazines.sql&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-u&lt;/code&gt; and &lt;code&gt;-p&lt;/code&gt; are needed for authentication, and is then followed by the name of the database you want to import into.&lt;/li&gt;
&lt;li&gt;You'll need to specify the path to your SQL dump file that will contain your import data: &lt;code&gt;~/backup/database/magazines.sql&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;You won't need to use &amp;gt; or &amp;lt; for importing, but you will need them for exporting in the next guide.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;This will prompt a password request.&lt;/li&gt;
&lt;li&gt;Your file will be automatically imported.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Export a SQL file using mysqldump
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;To export a MySQL database to a test file, start by using the &lt;code&gt;mysqldump&lt;/code&gt; command.&lt;/li&gt;
&lt;li&gt;Log in to MySQL.&lt;/li&gt;
&lt;li&gt;Enter the &lt;code&gt;mysqldump&lt;/code&gt; command using the following flags and options: &lt;code&gt;$ mysqldump -u my_username -p database_name &amp;gt; output_file_path&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;-u&lt;/code&gt; flag specifies the MySQL username.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;-p&lt;/code&gt; flag specifies a password prompt associated with the above username.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;database_name&lt;/code&gt; is the name of the database you want to export.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;&amp;gt;&lt;/code&gt; symbol is a Unix directive for STDOUT, which will make it possible for Unix commands to output the subsequent results of the output command to another location. These locations are usually file paths.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Be sure to input the completely qualified path and its filename to your output file path, so that your file will be placed exactly where you want it to be.&lt;/li&gt;
&lt;li&gt;Once the command is executed, you'll be prompted to enter your password. This will then create your exported backup file with a .sql extension.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After entering this command, you may be asked to enter the password for the MySQL user that you used.&lt;/li&gt;
&lt;li&gt;Please be careful when using an existing database that has records as this command will overwrite your existing database and end up losing your records.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Automate MySQL Backups with &lt;a href="https://simplebackups.io/mysql-backup/"&gt;SimpleBackups&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;SimpleBackups is a database and website backup automation tool. SimpleBackups automates MySQL backups by using MySQLDump to securely send backup files offsite to the cloud for storage. When you need to ensure your MySQL backups are secure, you can trust SimpleBackups to take care of it for you.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>database</category>
      <category>webdev</category>
    </item>
    <item>
      <title>MySQL Errors Messages And Common Problems</title>
      <dc:creator>SimpleBackups</dc:creator>
      <pubDate>Mon, 07 Dec 2020 14:12:22 +0000</pubDate>
      <link>https://dev.to/simplebackupsio/mysql-errors-messages-and-common-problems-3c11</link>
      <guid>https://dev.to/simplebackupsio/mysql-errors-messages-and-common-problems-3c11</guid>
      <description>&lt;p&gt;Errors or mistakes are common in any aspects, especially in development. Using MySQL or any database can't guarantee you an error-free environment.&lt;/p&gt;

&lt;p&gt;In this article, we will discuss the structure or anatomy of MySQL errors and how to read them. We've also picked the top 10 most common MySQL errors and their description.&lt;/p&gt;

&lt;h2&gt;
  
  
  The anatomy of MySQL errors
&lt;/h2&gt;

&lt;p&gt;Each MySQL errors consists of the following parts that identify the error:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ERROR NUMBER&lt;/strong&gt; is a unique number that identifies each error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SQLSTATE&lt;/strong&gt; is a code which identifies SQL error conditions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ERROR MESSAGE&lt;/strong&gt; describes the error in human readable format.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's an example MySQL error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR 1146 (42S02): Table 'test.no_such_table' doesn't exist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;1146&lt;/strong&gt; is the &lt;strong&gt;ERROR NUMBER&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;42S02&lt;/strong&gt; is the &lt;strong&gt;SQLSTATE&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Table 'test.no_such_table' doesn't exist&lt;/strong&gt; is the &lt;strong&gt;ERROR MESSAGE&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common MySQL Errors
&lt;/h2&gt;

&lt;p&gt;Here are the lists of most common MySQL errors:&lt;/p&gt;

&lt;h3&gt;
  
  
  ERROR 1045 (HY000): Access denied for user 'root'@'localhost' (using password: YES)
&lt;/h3&gt;

&lt;p&gt;This one is probably encountered at least once by anyone using MySQL. This error can have many causes, such as wrong username and/or password, or lacks of permission to the database.&lt;/p&gt;

&lt;h3&gt;
  
  
  ERROR 2013: Lost connection to MySQL server during query
&lt;/h3&gt;

&lt;p&gt;This error happens when the connection between your MySQL client and database server times out. Essentially, it took too long for the query to return data so the connection gets dropped.&lt;/p&gt;

&lt;h3&gt;
  
  
  ERROR 1040: Too many connections
&lt;/h3&gt;

&lt;p&gt;This error means that all available connections are in use by other clients.&lt;/p&gt;

&lt;h3&gt;
  
  
  ERROR 2006 (HY000): MySQL server has gone away
&lt;/h3&gt;

&lt;p&gt;The common reason for this error is that the server timed out and closed the connection. By default, the server closes the connection after 8 hours if nothing has happened. &lt;/p&gt;

&lt;h3&gt;
  
  
  ERROR 2008: MySQL client ran out of memory
&lt;/h3&gt;

&lt;p&gt;This means that MySQL does not have enough memory to store the entire query result:&lt;/p&gt;

&lt;h3&gt;
  
  
  ERROR 1114 (HY000): The table is full
&lt;/h3&gt;

&lt;p&gt;If a table-full error occurs, it may be that the disk is full or that the table has reached its maximum size. The effective maximum table size for MySQL databases is usually determined by operating system constraints on file sizes, not by MySQL internal limits.&lt;/p&gt;

&lt;h3&gt;
  
  
  ERROR: Packet too large
&lt;/h3&gt;

&lt;p&gt;When a MySQL client or the &lt;strong&gt;mysqld&lt;/strong&gt; server gets a packet bigger than &lt;strong&gt;max_allowed_packet&lt;/strong&gt; bytes, it issues a &lt;strong&gt;Packet too large&lt;/strong&gt; error and closes the connection.&lt;/p&gt;

&lt;p&gt;A 1 GB packet size is the largest possible packet size that can be transmitted to or from the MySQL server or client. The MySQL server or client issues an &lt;strong&gt;ER_NET_PACKET_TOO_LARGE&lt;/strong&gt; error and closes the connection if it receives a packet bigger than &lt;strong&gt;max_allowed_packet&lt;/strong&gt; bytes.&lt;/p&gt;

&lt;h3&gt;
  
  
  ERROR: Communication Errors and Aborted Connections
&lt;/h3&gt;

&lt;p&gt;If you find errors like the following in your error log.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;010301 14:38:23  Aborted connection 854 to db: 'users' user: 'simplebackups'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means that something of the following has happened:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The client program did not call &lt;strong&gt;mysql_close()&lt;/strong&gt; before exit.&lt;/li&gt;
&lt;li&gt;The client had been sleeping more than &lt;strong&gt;wait_timeout&lt;/strong&gt; or &lt;strong&gt;interactive_timeout&lt;/strong&gt; without doing any requests. &lt;/li&gt;
&lt;li&gt;The client program ended abruptly in the middle of the transfer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ERROR: Can’t create/write to file
&lt;/h3&gt;

&lt;p&gt;This indicates that MySQL is unable to create a temporary file in the temporary directory for the result set if we get the following error while executing a query.&lt;/p&gt;

&lt;h3&gt;
  
  
  ERROR: Commands out of sync
&lt;/h3&gt;

&lt;p&gt;If you get this error in your client code, you are calling client functions in the wrong order. For example, if you are using &lt;strong&gt;mysql_use_result()&lt;/strong&gt; and try to execute a new query before you have called &lt;strong&gt;mysql_free_result()&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Automate MySQL Backups with &lt;a href="https://simplebackups.io/mysql-backup/"&gt;SimpleBackups&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;SimpleBackups is a database and website backup automation tool. SimpleBackups automates MySQL backups by using MySQLDump to securely send backup files offsite to your cloud storage. When you need to ensure your MySQL backups are secure, you can trust SimpleBackups to take care of it for you.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>database</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
