
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we create user accounts in MySQL database server?
As we know that, MySQL database server is having the user table in MySQL database which is used to store the user accounts so by using MySQL database we can create user accounts in MySQL database server. There must be two things while creating the new user account, one is the username and other is the hostname which is after @ character. The syntax for creating the user account is as follows −
Syntax
Use mysql; CREATE USER user_account IDENTIFIED BY password;
Here user_account is the name of the user we wish to take account of. It can be like username@hostname.
The password is the password we wish to make for user_account. With the help of this password, MySQL server will identify this user.
Example
In the example below we are creating a user named abcd@localhost under user table of MySQL database −
mysql> use mysql Database changed mysql> create user abcd@localhost identified by 'password123'; Query OK, 0 rows affected (0.04 sec)
The query below will give us the privileges for the new user account abcd@localhost.
mysql> SHOW GRANTS FOR abcd@localhost; +------------------------------------------+ | Grants for abcd@localhost | +------------------------------------------+ | GRANT USAGE ON *.* TO 'abcd'@'localhost' | +------------------------------------------+ 1 row in set (0.01 sec) Questi
- Related Articles
- How to Create Multiple User Accounts in Linux?
- How can we create our own choice MySQL database?
- After connecting to MySQL server how can we select a database from\ncommand prompt?
- How can we create a MySQL user account by omitting the hostname?
- Create manage user accounts using utility netplwiz
- How can we analyze the tables of a particular database from MySQL Server command line?
- How to get a list of MySQL user accounts?
- How can we get the list of tables in a particular database from MySQL Server command line?
- How can we get “MySQL server-side help”?
- How can we create a table from an existing MySQL table in the database?
- Can we create a database with a numeric name with MySQL?
- Check user rights before attempting to CREATE MySQL DATABASE?
- What is MySQL CREATE command? How can we create both database and table with this command?
- How can we grant privileges to a MySQL user?
- How can we revoke privileges from a MySQL user?
