SQL

Create a MySQL Database and a Username.

We’ll show you how to make a CNCC user and a CNCC database in this article.

1. Log in to the server or machine that has access to the NDB cluster’s SQL nodes.

2. Now, one by one, connect to the SQL nodes of the NDB cluster.

3. Run the following command and To login to the MySQL prompt using root permission or a user who has access to create users with permissions.

  • Note: After running the program, the user must input the MySql password.
mysql -h -uroot -p

4. Create a CNCC user if one does not already exist by running the following commands and Verify whether a CNCC user already exists.

  • Execute $ SELECT User FROM mysql.user; to list the users
  • Create a new user if one does not already exist $ CREATE USER '<CNCC User Name>'@'%' IDENTIFIED BY '<CNCC Password>';

5. Create a CNCC database if one does not already exist, and provide rights to the CNCC user established in the preceding step. Examine the CNCC database to see whether it already exists.

a. Execute $ show databases; to check if the database exists

b. Drop the CNCC database created in MySql as of version 1.0.0 before generating cnccdb using the following command:

DROP DATABASE cnccdb

c. Execute $ CREATE DATABASE IF NOT EXISTS <CNCC Database> CHARACTER SET utf8; for Database creation.

d. Execute the following command to grant permission to the user.

$ GRANT SELECT,INSERT,CREATE,ALTER,DROP,LOCK TABLES,CREATE TEMPORARY TABLES, DELETE,UPDATE,EXECUTE ON <CNCC Database>.* TO '<CNCC User Name>'@'%';

To show how to create a cncc user, a cnccdb, and provide rights to a cncc user, consider the following scenario:

# Login to MySql prompt:-
$ mysql -u root -p
Check user already exists or not
$ SELECT User FROM mysql.user;
# In case, user already exists, move to next step. Command to create new user is as mentioned below:-
$ CREATE USER 'cnccusr'@'%' IDENTIFIED BY 'cnccpasswd'
# Command to check if database exists:-
$ show databases;
# Check if required database is already in list. If MySql has cnccdb already created as per 1.0.0 release creation, drop it.  
$ DROP DATABASE cnccdb;
# Database creation for CNCC
$ CREATE DATABASE IF NOT EXISTS cnccdb CHARACTERSET utf8;
#Granting permission to user:-
$ GRANT SELECT, INSERT, CREATE, ALTER, DROP, LOCK TABLES, CREATE TEMPORARY TABLES, DELETE, UPDATE, EXECUTE ON cnccdb .* TO'cnccusr'@'%';

We genuinely hope you now have a better understanding of Create a MySQL database and a username. If you continue to have problems with the method outlined above, please contact the bodHOST Team for assistance. 24×7

Leave a Reply

Your email address will not be published.