在 CentOS 上“导入数据库”通常有两种常见场景:MySQL / MariaDB 和 PostgreSQL。下面分别说明最常用的方法。
mysql -u root -p
CREATE DATABASE testdb CHARACTER SET utf8mb4;
exit
mysql -u root -p testdb < /path/to/file.sql
USE testdb;
SOURCE /path/to/file.sql;
su - postgres
psql
CREATE DATABASE testdb;
psql testdb < /path/to/file.sql
或使用:
\i /path/to/file.sql
utf8mb4(MySQL)mysql -u root -p --init-command="SET autocommit=0;" testdb < file.sql
mysql -h 127.0.0.1 -P 3306 -u user -p dbname < file.sql
可以告诉我:
我可以给你更精确的命令示例。