Home  >  Article  >  Database  >  Create and select a MySQL database

Create and select a MySQL database

WBOY
WBOYforward
2023-09-10 14:41:06663browse

创建并选择 MySQL 数据库

Create database

You can use the following statement to create a database-

CREATE DATABASE databaseName;

Example

CREATE DATABASE STUDENT

Select MySQL database

If we wish to access and use a specific database, we can use the following query -

Query

mysql> USE databaseName
Database changed

Example

USE STUDENT

The "USE" statement does not require a semicolon. This is similar to the "QUIT" statement. Even using a semicolon doesn't hurt.

We can create and use our own database, but before doing so, we need MySQL administrator permissions.

MySQL administrator can execute the command as shown below to provide permissions -

mysql> GRANT ALL ON tableName.* TO ‘your_mysql_name’@’your_client_host’;

Here, "your_mysql_name" refers to the MySQL username assigned to the user.

"your_client_host" refers to the host where the user connects to the server.

The above is the detailed content of Create and select a MySQL database. For more information, please follow other related articles on the PHP Chinese website!

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