News
Seven days of Black Friday madness — great deal from Serverspace!
Serverspace Black Friday
RF
September 12, 2023
Updated September 13, 2023

How to Create MySQL User and Grant Privileges?

Databases Linux

Introduction

Databases play a crucial role in efficiently storing and managing vast volumes of data. They streamline the process of data updates, enhancing reliability and accuracy while minimizing redundancy. These are some of the compelling reasons why databases are indispensable:

  • Data Storage: Databases have the capacity to store massive datasets, making them the go-to choice for businesses, governments, and organizations dealing with extensive data.
  • Data Organization: Databases structure data in an organized manner, simplifying data retrieval and ensuring that the required information is easily accessible.
  • Data Security: Robust security measures, including password protection, safeguard data in databases against unauthorized access, bolstering data protection.
  • Data Management: Databases offer an array of data management features, encompassing data backup and recovery, data compression, and data replication, facilitating effective data administration.
  • Data Analysis: Databases serve as powerful tools for data analysis, enabling the extraction of valuable insights and informed decision-making.

Databases find application in various domains, exemplifying their versatility:

  • Businesses: Utilized for storing customer data, inventory records, financial information, and critical business data.
  • Governments: Employed to house citizen data, tax records, and government archives.
  • Schools: Essential for maintaining student records, teacher information, and academic data.
  • Hospitals: Vital in healthcare settings for preserving patient data, medical histories, and healthcare-related information.
  • E-commerce: Integral to e-commerce platforms, housing product listings, order histories, and customer profiles.

In essence, databases are indispensable tools for the efficient management of large datasets across diverse environments. Whether the goal is data storage, organization, security, management, or analysis, a database proves to be an essential asset.

User creation

Let's examine MySQL, assuming it's already installed as database software with administrative privileges. To begin, we'll initiate access to the MySQL system by entering the following command:

mysql -u root -p -h localhost
Login
Screenshot №1 — Login

Now we can create user in several ways by using CLI of client MySQL or GUI web to interact. In that instruction we will consider CLI version of interaction with server, for create type command below:

CREATE USER 'ff'@'localhost' Identified by 'password';

And on the screenshot below we can see next command to set privileges:

GRANT ALL on *.* to 'ff'@'localhost';
Creation of user
Screenshot №2 — Creation of user

The 'ff'@'localhost' means 'name_of_user'@'host' which you use to connect to the DBMS. In the next command ALL means all rights to the setting databases, you can grant privileges on the table or object level by turning on parameter. For example, GRANT ALL on product. that means we grant access to the determine table witn label product! Also you can grant only limited list of rights and commands. For example, GRANT create,drop,insert. Let's check that:

Grant CREATE,DROP on product.* to 'ff'@'localhost';
Grant
Screenshot №3 — Grant

Query OK means all command are execute properly!

Conclusion

In this instruction, we explored the process of creating a user in MySQL, emphasizing the significance of access control and privileges, which are fundamental aspects of database administration. By understanding these principles, users can harness the full potential of their databases to effectively manage and utilize their data resources.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 2
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.