OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.2.5

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.2.5
    iconOceanBase Database
    SQL - V 4.2.5
    SQL
    KV
    • V 4.6.0
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    CREATE USER

    Last Updated:2026-04-27 03:14:13  Updated
    share
    What is on this page
    Purpose
    Required privileges
    Syntax
    Parameters
    Examples
    References

    folded

    share

    Purpose

    You can use this statement to create an OceanBase Database user. After you create a user, you can use it to connect to OceanBase Database.

    Required privileges

    To execute the CREATE USER statement, you must have the global CREATE USER privilege. For more information about privileges in OceanBase Database, see Privilege types in MySQL mode.

    Syntax

    CREATE USER [IF NOT EXISTS] {user [, user...]}
        [REQUIRE {NONE | SSL | X509 | tls_option}]
        [WITH resource_option [resource_option...]];
    
    user:
          user_name
        | user_name IDENTIFIED [WITH auth_plugin] BY password
        | user_name IDENTIFIED [WITH auth_plugin] BY PASSWORD password
    
    tls_option:
          CIPHER cipher_name
        | ISSUER issuer_name
        | SUBJECT subject_name
    
    resource_option:
          MAX_CONNECTIONS_PER_HOUR integer
        | MAX_USER_CONNECTIONS integer  
    

    Parameters

    Parameter
    Description
    IF NOT EXISTS Specifies not to create a user when the username already exists. If the username already exists and IF NOT EXISTS is not specified, an error is returned.
    user_name The username. For each user created, a new entry is created in the mysql.user table. To create multiple users at a time, use commas (,) to separate them.
    auth_plugin The user authentication method. Currently, only the mysql_native_password authentication plug-in is supported.
    IDENTIFIED BY password The password in plaintext for the user, which is then saved to the mysql.user table in ciphertext. Enclose special characters in the password in quotation marks ('' or ""). Special characters are ~!@#%^&*_-+=`|(){}[]:;',.?/.
    IDENTIFIED BY PASSWORD password The password in ciphertext for the user, which is saved to the mysql.user table directly.
    REQUIRE The authentication requirements for the user. Valid values:
    • NONE: No authentication requirement is imposed. In this case, the user can use any password or no password.
    • SSL: The user must use an SSL connection for authentication.
    • X509: The user must use an X509 certificate for authentication.
    • tls_option: The user must meet the specified Transport Layer Security (TLS) requirements.
    tls_option The options for TLS requirements. Valid values:
    • CIPHER: the encryption algorithm or cipher suite used for the TLS connection.
    • ISSUER: the issuer of the TLS certificate.
    • SUBJECT: the subject of the TLS certificate.
    resource_option The resource options for the user. Separate multiple resource options with spaces.
    • MAX_CONNECTIONS_PER_HOUR: the maximum number of connections allowed per hour. The value must be an integer.
    • MAX_USER_CONNECTIONS: the maximum number of connections allowed per user. The value must be an integer.

    Examples

    • Create users named test1 and test2, and specify passwords in plaintext and the maximum number of concurrent connections allowed per user.

      obclient> CREATE USER IF NOT EXISTS test1 IDENTIFIED BY '********', test2 IDENTIFIED BY '********' WITH MAX_USER_CONNECTIONS 10;
      
    • Create a user named test3, specify a password in ciphertext, and specify to use an SSL connection for authentication.

      obclient> CREATE USER IF NOT EXISTS test3 IDENTIFIED BY PASSWORD '********' REQUIRE SSL;
      
    • Create a user named test4 and specify to use the mysql_native_password authentication plug-in.

      obclient> CREATE USER IF NOT EXISTS test4 IDENTIFIED WITH mysql_native_password BY PASSWORD '********';
      

    References

    • For more information about how to grant user privileges, see Grant direct privileges.

    • You can query the information about the created user in the mysql.user table. For more information about the mysql.user table, see mysql.user.

    • For more information about how to use the created user to connect to OceanBase Database, see Connect to OceanBase Database.

    Previous topic

    CREATE TABLESPACE
    Last

    Next topic

    CREATE VIEW
    Next
    What is on this page
    Purpose
    Required privileges
    Syntax
    Parameters
    Examples
    References