Home > Database > Mysql Tutorial > Create and select a MySQL database

Create and select a MySQL database

WBOY
Release: 2023-09-10 14:41:06
forward
693 people have browsed it

创建并选择 MySQL 数据库

Create database

You can use the following statement to create a database-

CREATE DATABASE databaseName;
Copy after login

Example

CREATE DATABASE STUDENT
Copy after login

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
Copy after login

Example

USE STUDENT
Copy after login

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’;
Copy after login

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!

source:tutorialspoint.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