![]() I've wrapped the string to 50 columns for readability on Stack Overflow.Be sure base64 and MySQL agree on what the character encoding is (I recommend UTF-8). Base64-encoding is a binary encoding, so you'd better make sure that you get your character set correct when you do the encoding, because MySQL is going to decode the Base64-encoded string into bytes and then interpret those.Z1NTQW5aRzl1SjMKUWdablZzWm1sc2JDQnlaWEYxYVhKbGJXVn JoMElFa25aQ0JoY0hCc2VTd2dZblYwSUdGd2NHRnlaVzUwYkhr SGRoYm5SbApaQ0IwYnlCcWIybHVMaUF1SUM0Z0xpQlVhRzkxWj MFpYCklnYjJZZ2JtOGdhVzF3YjNKMFlXNWpaUzRnTGlBdUlDNGĭTWFFuY3lCdWIzUWdZWE1nZEdodmRXZG9JRWtnY21WaGJHeDVJ JGMlpXUWdZVzRnWld4bFoyRnVkQ0JvWVc1a0xDQWlZU0J0WVhS SWtGb0xDSWdUbVZoY214NUlFaGxZV1JzWlhOeklFNXBZMnNnZD ![]() Instead, you can Base64-encode the text, so you have a "clean" string: But, if you have to put that into a SQL script, you'll have to edit the text (to escape the quotes) which could be error prone or sensitive to word-wrapping, etc. ![]() If you are inserting that from a program, it's easy to escape the quotes, etc. That quote has a bunch of single- and double-quotes and would be a real pain to insert into MySQL. Thought I'd apply, but apparently I 'don't fulfill requirements' -" It's not as though I really wanted to join. "Ah," Nearly Headless Nick waved an elegant hand, "a matter of no importance. Let's say you have this message you'd like to insert: It requires MySQL 5.6 or later because of the use of a specific string function: FROM_BASE64. ("One Big Database User" model.There is another way to do this which may or may not be safer, depending upon your perspective. SELECT := erid from usertab where username = and password = people please accept the following better-protected solution: SELECT = primary problem arises from having all users connect as the same database user. Then you'd use that to fill a session variable you could later use in your trigger. You would have to prompt the user for a user name, or perhaps a username and password. You would need to revise the code that connects the user to the database, and set a session variable correspondingly, right after login. If you are using MySQL 5.1.7 or later, and if you have your users connecting directly from their PCs to the database, and their PCs have meaningful names like AWOLFE_LAPTOP, then you can put that value into your audit table: SELECT host FROM information_schema.processlist WHERE id = connection_id()Īpart from the logged-in user name (which your comment makes clear is unavailable) and the client machine ("host") name, I don't know of any reliable way to identify the user without changing your application. ![]() In this case you would need to query various connection information from mysql. In this case you want to get session information about your end user. Second, if all users employ the same database connection (very common). Record CURRENT_USER() into your auditing table with each modification and you can track which user did what. ![]() For example, if you have a user "annamaria" then in your trigger you can identify the user with the CURRENT_USER() function. There are several options, but here are two based on two options for how your end-users connect.įirst, if your users connect as themselves. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |