How to Change a MySQL Privilege Table

There will be times when multiple users need to access the same database, at which point you will need to change the MySQL privilege table. Depending on user needs, you may provide limited or full access to the database. MySQL provides a mechanism to implement that type of change in the privilege table using the GRANT command.

Instructions

  1. Change a MySQL Privilege Table

    • 1

      Log in as root or another admin user. To use the GRANT command in MySQL, it's necessary to be root or another privileged user. From the command-line MySQL client, connect to the database as root. Example:
      mysql -u root -h localhost

    • 2

      Replace localhost with your database host, unless you are running the MySQL server on the same computer you are using. Otherwise, use the hostname of your MySQL server. Example:
      mysql -u root -h localhost -p

    Grant 'Read' Privileges

    • 3

      Grant read privileges to a user if she doesn't need to change any data. For example, if the marketing department wants access to your customer database, you could give them read-only access to the customer database.

    • 4

      Accomplish this with the three-part GRANT command from the root user. To change privileges, GRANT needs to command who has access privileges to which databases and tables, and what passwords they should use to login. In this example, the GRANT command grants permission to use the SELECT command on all tables in the customers_db database. It gives permission to the user 'marketing' logging in from 'localhost,' who is identified by the password 'some_password'. Example:
      GRANT SELECT ON customers_db.*
      TO 'marketing'@'localhost'
      IDENTIFIED BY 'some_password';

    Grant 'Write' Privileges

    • 5

      Grant write privileges to a user. This command takes the same form as granting read privileges but adds more commands with SELECT.

    • 6

      Identify what type of privileges the user will need. Here the command grants the accounting department permission to INSERT and UPDATE, as well as SELECT data from the customer databases. Example:
      GRANT SELECT,INSERT,UPDATE ON customers_db.*
      TO 'accounting'@'localhost'
      IDENTIFIED BY 'some_password';

    Grant 'Admin' Privileges

    • 7

      Grant admin privileges to a user. This command grants permissions to run all commands.

    • 8

      Use this command to give other admins full control over a database. Example:
      GRANT ALL PRIVILEGES ON customers_db.*
      TO 'admin'@'localhost'
      IDENTIFIED BY 'some_password'

Tips & Warnings

  • On a default install, there is no password on the root user. Once one is set, you'll have to use the -p switch, as well.

  • Limiting user access guards against human error, faulty software and malicious users. This means that novice users or a software bug can't accidentally delete all the data. If someone gains control of a minor account, they can't do much damage.

Related Searches:

Resources

Comments

You May Also Like

  • How to Change User Privileges

    User authentication in the Windows operating system prevents unauthorized use of the computer by requiring a valid user ID and password for...

  • MySQL Permissions Tutorial

    MySQL provides permissions (privileges) based on the level of operation of the user. Administrative privileges manage the operation of the server. Database...

  • How to Change the Field Name in a MySQL Table

    The MySQL "alter table" command is used to change the name of a field (column) in a table. To use this command...

  • How to Grant Access to a MySQL Database

    Do you have a MySQL database and need to grant access so that a new user can create, remove, update, and delete...

  • How to Update a Table in MySQL

    A database helps to keep your information in order. The MySQL database management system helps you keep the hundreds or even thousands...

  • How To Change MySQL Root Password

    The MySQL database application has an administrator account called "root." This user has complete administrative control over all aspects of the database....

  • MySQL Administration Tutorials

    Two of the most common administration tasks for the MySQL server are creating and managing user accounts and monitoring system logs. User...

  • How to Create a MySQL Table

    Creating a MySQL table utilizes the CREATE command and the "Data Definition Language," or DDL. DDL is used to define data structures....

  • Grant Writing Tutorial

    If you run a small business, nonprofit organization or environmental project, you may find yourself needing grant funding. If you are looking...

  • MySQL Linux Tutorials

    MySQL is an enterprise-ready, open source database used by individual web developers as well as companies such as Yahoo!, Google and YouTube....

  • How to Undelete the Root Account for MySQL

    If you've ever locked your keys in a car, you're already familiar with the sinking feeling you'll get after realizing you've deleted...

  • How to Remove Select Grant Microsoft SQL Database Table

    Microsoft SQL Server is a Relational Database Management System RDMS which includes rich built in security features. Granting and revoking specific rights...

  • How to Change a User Password in SQL

    Structured Query Language (SQL) provides database developers with the commands required to edit data objects. The language also includes a command to...

  • How to Use PHP 5 and MySQL

    This article will teach users with a basic knowledge of PHP 5 and database structure to create a connection to a database,...

  • How to optimize mysql

    MySQL is a database engine similar to postgresql, oracle, or Ms SQL server in that it allows you to create tables and...

  • How to Change the Column Name in MYSQL

    Sometimes a MySQL database designer does not know the appropriate column name for data until after he has designed and implemented a...

  • How to Set Up MySQL Remote Access

    Remote access allows users and applications to connect to a MySQL database from a location other than the server running the database....

  • How to Change a User's Privileges on Vista

    Change a user's profile in Windows Vista operating system by clicking Start, Control Panel, User Accounts and clicking Manage Another Account. Switch...

  • MySQL and Access Tutorial

    Microsoft Access is a desktop application that allows users to create database records. The MySQL and Access software can be joined together...

Related Ads

Featured