Home  >  Article  >  Database  >  How to execute sql script in mysql

How to execute sql script in mysql

PHPz
PHPzforward
2023-05-29 22:13:0511499browse

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

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

Check the table

show tables;

Check whether there is data in the table

select * from sys_role;

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete