Focus on cloud service provider activities
Notes on website operation and maintenance

Linux VPS uses the command to quickly import/back up the MYSQL database

In use Linux VPS When building a website, if the database of the website is small, if I need to import the database to move to the website or other needs, Lao Zuo must use phpmyadmin to import and manage database files online. When I moved to a website today, the database was more than 100M. If I import it online, I don't know how long it will take. In addition, I found that the maximum database imported by online phpmyadmin is 50M.

In this case, I will use the SSH command to import the database. It is straightforward. Friends in need will remember the following commands directly:

Standard command: mysql - u database user name - p database password database name<database file name.sql

Example case: mysql - ulaozuo - laozuo.org laozuo<laozuo.sql

There is no explanation. Just look at the above comparison. - u and - p are directly next to each other, and there is no space between them and the user name and password. However, it should be noted that we need to download the laozuo.sql database from outside and put it in the root directory of this website. The import is then automatically detected.

Similarly, how do we back up database files?

Standard command: mysqldump - u database username - p database password -- default character set=encoding database name>database filename.sql

Example case: mysqldump - ulaozuo - laozuo. org -- default character set=gb2312 laozuo>laozuo.sql

There are two problems to pay attention to here. The first is coding. According to the code of your website database, whether it is gb2312 or utf-8, and the database file name will be saved in the root directory of the website. Then we can download through FTP or wget.

In this way, we can solve the problem of websites with large databases through the above import and backup databases. It can achieve twice the result with half the effort.

Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( four )
Do not reprint without permission: Lao Zuo's Notes » Linux VPS uses the command to quickly import/back up the MYSQL database


Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge