<?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: egang</title>
    <description>The latest articles on DEV Community by egang (@545900658).</description>
    <link>https://dev.to/545900658</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%2F3549405%2F0575f255-0ec3-4359-9746-99d7492111c1.png</url>
      <title>DEV Community: egang</title>
      <link>https://dev.to/545900658</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/545900658"/>
    <language>en</language>
    <item>
      <title>How to Import a MySQL Database Using Command Line</title>
      <dc:creator>egang</dc:creator>
      <pubDate>Mon, 06 Oct 2025 16:31:31 +0000</pubDate>
      <link>https://dev.to/545900658/how-to-import-a-mysql-database-using-command-line-272n</link>
      <guid>https://dev.to/545900658/how-to-import-a-mysql-database-using-command-line-272n</guid>
      <description>&lt;p&gt;While building a website, you may often need to upload data or import/export databases. Today, I needed to import a database during my web development process, so I’m sharing this note in hopes it will help others who encounter the same task.&lt;/p&gt;

&lt;p&gt;In this example, I’ll demonstrate how to import a MySQL database on a Linux server running CentOS 7.9 with an LNMP environment.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Log in to the Server&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can use SSH tools such as Xshell to connect to your server. (You can find and download it from websites like Baidu or CSDN.)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create and Import a Database&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you’re importing a new database, you’ll first need to create one. Below are the steps to log in to MySQL, create a new database, and import data.&lt;/p&gt;

&lt;p&gt;1) Log in to MySQL&lt;br&gt;
mysql -uroot -p&lt;/p&gt;

&lt;p&gt;Enter your root password when prompted, then press Enter.&lt;/p&gt;

&lt;p&gt;2) Create a New Database&lt;/p&gt;

&lt;p&gt;It’s best to choose a database name that’s easy to remember, such as your website domain.&lt;br&gt;
For example:&lt;/p&gt;

&lt;p&gt;create database &lt;a href="http://www.wativate.com" rel="noopener noreferrer"&gt;www.wativate.com&lt;/a&gt;;&lt;/p&gt;

&lt;p&gt;3) Select the Database&lt;br&gt;
use &lt;a href="http://www.wativate.com" rel="noopener noreferrer"&gt;www.wativate.com&lt;/a&gt;;&lt;/p&gt;

&lt;p&gt;4) Set the Character Encoding&lt;br&gt;
set names utf8mb4;&lt;/p&gt;

&lt;p&gt;5) Import the Database&lt;/p&gt;

&lt;p&gt;First, upload your SQL file (e.g., 20251006.sql) to your server—commonly to the /home directory.&lt;br&gt;
You can use tools like WinSCP to transfer files from your computer to the server.&lt;/p&gt;

&lt;p&gt;Then run the import command:&lt;/p&gt;

&lt;p&gt;source /home/20251006.sql;&lt;/p&gt;

&lt;p&gt;6) Exit MySQL&lt;br&gt;
exit;&lt;/p&gt;

&lt;p&gt;Notes&lt;br&gt;
Always double-check that you’ve selected the correct database before importing, to avoid overwriting or importing data into the wrong one.&lt;br&gt;
Once the import is complete, you can verify your tables and data using show tables;.&lt;/p&gt;

</description>
      <category>cli</category>
      <category>tutorial</category>
      <category>linux</category>
      <category>mysql</category>
    </item>
  </channel>
</rss>
