Langsung ke konten utama

Adding the new MySQL user

Connect to your database as root, then add your new user like so:
CREATE USER 'tester'@'%' IDENTIFIED BY 'password';
The % here means the user 'tester' connecting from any host, you can place a network hostname here instead if you want to restrict access further. Naturally you will also want to substitute password with something a little stronger ;-)
Now run the following to grant the SELECT privilage to the new user on all databases:
GRANT SELECT ON *.* TO 'tester'@'%';
Or if you want to restrict access to only one database:
GRANT SELECT ON DATABASE.* TO 'tester'@'%';

Confirming that it worked

Connect as the new user:
mysql -u tester -p
And now see if you can update a record:
mysql> USE alpha;
mysql> UPDATE Person SET version_num = 5 WHERE OID = 1;
ERROR 1142 (42000): UPDATE command denied TO USER 'tester'@'localhost' FOR TABLE 'Person'

http://www.alphadevx.com/a/388-Adding-a-read-only-MySQL-user

Komentar

Postingan populer dari blog ini

REGEX: Regular Expressions

  Standards [ edit ] The  IEEE   POSIX  standard has three sets of compliance:  BRE  (Basic Regular Expressions), [29]   ERE  (Extended Regular Expressions), and  SRE  (Simple Regular Expressions). SRE is  deprecated , [30]  in favor of BRE, as both provide  backward compatibility . The subsection below covering the  character classes  applies to both BRE and ERE. BRE and ERE work together. ERE adds  ? ,  + , and  | , and it removes the need to escape the metacharacters  ( )  and  { } , which are  required  in BRE. Furthermore, as long as the POSIX standard syntax for regexes is adhered to, there can be, and often is, additional syntax to serve specific (yet POSIX compliant) applications. Although POSIX.2 leaves some implementation specifics undefined, BRE and ERE provide a "standard" which has since been adopted as the default syntax of many tools, where the choi...

Difference: SQL UNION vs UNION ALL?

  Difference: SQL UNION vs UNION ALL ? UNION and UNION ALL are both used to retrieve records from multiple tables. This article will detail the differences between the two, allowing you to make the best choice for each unique scenario. You can use SQL’s  UNION  and  UNION ALL  commands to get data from multiple tables in your database. It’s a common use case, considering that most databases have many tables. Both  UNION  and  UNION ALL  are known as set operators. In SQL, set operators combine the results of two or more queries into a single result. You can  read more about set operators in this article . When comparing  UNION  vs.  UNION ALL , there is one major difference: UNION  only returns  unique UNION ALL  returns  all  records, including duplicates. If you feel like you would benefit from a well-structured, comprehensive course that covers foundational SQL, consider this  SQL...

Error when install new Instance or SSIS SQL Server 2008

Error : attributes do not match. present attributes (directory compressed) included attributes (0) Cause:  Sql server will validate the installation folder during the setup process to check if no Archive attribute as set on the installation folder The installation folder includes “C:\Program Files\Microsoft SQL Server and if you have it C:\Program Files (x86)\Microsoft SQL Server.”  Solution: - Go to SQL server installation directory - C:\Program Files\Microsoft SQL Server - C:\Program Files (x86)\Microsoft SQL Server - Right click on the folder and go to properties - Click on general tab and click on Advanced and uncheck the option “Folder is ready for archiving” - Try doing the installation again it will be successful