Guest User

Untitled

a guest
Feb 28th, 2012
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. # OK, I want to set the sql_mode variable for my session upon connection.
  2. # It's easy to do manually:
  3.  
  4. mysql> set sql_mode='STRICT_ALL_TABLES';
  5. Query OK, 0 rows affected (0.00 sec)
  6.  
  7. # I don't want to type that every time, though; I want to alias 'mysql' to automatically set it.
  8.  
  9. [dave@rasputin:~]$ mysql --help | grep -i var
  10. -O, --set-variable=name
  11. Change the value of a variable. Please note that this
  12. option is deprecated; you can set variables directly with
  13. --variable-name=value.
  14.  
  15. # Ah, OK, so --sql_mode=STRICT_ALL_TABLES then, that's easy...
  16.  
  17. [dave@rasputin:~]$ mysql --sql_mode=STRICT_ALL_TABLES
  18. mysql: unknown variable 'sql_mode=STRICT_ALL_TABLES'
  19.  
  20. # Sorry, what?
  21.  
  22. # Let's try --set-variable, even though it's deprecated...
  23. [dave@rasputin:~]$ mysql --set-variable=sql_mode=STRICT_ALL_TABLES
  24. mysql: unknown variable 'sql_mode=STRICT_ALL_TABLES'
  25. [dave@rasputin:~]$ mysql --set-variable=sql_mode STRICT_ALL_TABLES
  26. mysql: unknown variable 'sql_mode'
  27.  
  28. # Maybe it needs to be sql-mode, when passed as an option
  29. [dave@rasputin:~]$ mysql --sql-mode=STRICT_ALL_TABLES
  30. mysql: unknown variable 'sql-mode=STRICT_ALL_TABLES'
  31.  
  32. # OK, it doesn't seem to work.
  33.  
  34. # Maybe if I put it in ~/.my.cnf (I don't really want to do it that way, I want it done via
  35. # an alias in my .profile which is replicated to all boxes I use, but let's try anyway):
  36.  
  37. [dave@rasputin:~]$ grep sql_mode .my.cnf
  38. sql_mode=STRICT_ALL_TABLES
  39. [dave@rasputin:~]$ mysql
  40. mysql: unknown variable 'sql_mode=STRICT_ALL_TABLES'
  41.  
  42. # I'm lost.
  43.  
  44. # Versions:
  45. [dave@rasputin:~]$ mysql -V
  46. mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (x86_64) using readline 5.2
  47. [dave@rasputin:~]$ mysql -e 'select version()'
  48. +-----------------------+
  49. | version() |
  50. +-----------------------+
  51. | 5.0.51a-24+lenny4-log |
  52. +-----------------------+
Add Comment
Please, Sign In to add comment