MySQL

Find database version
mysql -e status|grep ‘Server version’

Display databases in mysql
show databases;

Character sets

It’s a good practice to add unicode support in the database, as it will support special characters in different languages. Norway have f.eks. æ,å and å.

To view which character sets are used by sql:
show variables like “%character%”;show variables like “%collation%”;

+————————–+—————————-+
| Variable_name            | Value                      |
+————————–+—————————-+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+————————–+—————————-+

+———————-+—————–+
| Variable_name        | Value           |
+———————-+—————–+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_general_ci |
+———————-+—————–+

Add this in /etc/mysql/my.cnf:

[mysqld] #Add utf support on server level
default-character-set = utf8

[mysql]
default-character-set = utf8

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>