Home > Database > Mysql Tutorial > How to execute sql script in mysql

How to execute sql script in mysql

PHPz
Release: 2023-05-29 22:13:05
forward
11570 people have browsed it

Similar to ordinary scripting languages, MySQL also has a set of rules for the use of characters, words and special symbols. MySQL completes database operations by executing SQL scripts. This script consists of one or more MySQL statements (SQL statement expansion statement), the suffix name of the script file is usually .sql. The MySQL client can also execute statements on the console without saving the statements as a .sql file.

The first method: Enter

 mysql -h localhost -u root -p123456 < F:\hello world\niuzi.sql
Copy after login

at the command line (not connected to the database). Note: does not need to be quoted in the path!!

Second method: Under the command line (the database is connected, the prompt at this time is mysql>)

Enter the mysql command line and execute another sql statement

source E:\sources\RuoYi\sql\quartz.sql
Copy after login

Check the table

show tables;
Copy after login

Check whether there is data in the table

select * from sys_role;
Copy after login

The above is the detailed content of How to execute sql script in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template