MySQL Error 1071

I want to use mysql as internal db.I have edited config.ini file just like that:

#################################### Database ############################
[database]
# You can configure the database connection by specifying type, host, name, user and password
# as separate properties or as on string using the url property.

# Either "mysql", "postgres" or "sqlite3", it's your choice
type = mysql
host = 192.168.10.152:3306
name = grafana
user = grafana
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password = grafana
# Use either URL or the previous fields to configure the database
# Example: mysql://user:secret@host:port/database
url = mysql://grafana:grafana@192.168.10.152:3306/grafana

and when I start grafana i got that error:

 bin/grafana-server 

INFO[06-20|12:40:51] Starting Grafana                         logger=main version=4.3.2 commit=ed4d170 compiled=2017-05-31T16:48:16+0800
INFO[06-20|12:40:51] Config loaded from                       logger=settings file=/root/software/grafana-4.3.2/conf/defaults.ini
INFO[06-20|12:40:51] Path Home                                logger=settings path=/root/software/grafana-4.3.2
INFO[06-20|12:40:51] Path Data                                logger=settings path=/root/software/grafana-4.3.2/data
INFO[06-20|12:40:51] Path Logs                                logger=settings path=/root/software/grafana-4.3.2/data/log
INFO[06-20|12:40:51] Path Plugins                             logger=settings path=/root/software/grafana-4.3.2/data/plugins
INFO[06-20|12:40:51] Initializing DB                          logger=sqlstore dbtype=mysql
INFO[06-20|12:40:51] Starting DB migration                    logger=migrator
INFO[06-20|12:40:51] Executing migration                      logger=migrator id="copy data account to org"
INFO[06-20|12:40:51] Skipping migration condition not fulfilled logger=migrator id="copy data account to org"
INFO[06-20|12:40:51] Executing migration                      logger=migrator id="copy data account_user to org_user"
INFO[06-20|12:40:51] Skipping migration condition not fulfilled logger=migrator id="copy data account_user to org_user"
INFO[06-20|12:40:51] Executing migration                      logger=migrator id="Add index for plugin_id in dashboard"
EROR[06-20|12:40:51] Executing migration failed               logger=migrator id="Add index for plugin_id in dashboard" error="Error 1071: Specified key was too long; max key length is 767 bytes"
EROR[06-20|12:40:51] Exec failed                              logger=migrator error="Error 1071: Specified key was too long; max key length is 767 bytes" sql="CREATE INDEX `IDX_dashboard_org_id_plugin_id` ON `dashboard` (`org_id`,`plugin_id`);"
**EROR[06-20|12:40:51] Fail to initialize orm engine            logger=sqlstore error="Sqlstore::Migration failed err: Error 1071: Specified key was too long; max key length is 767 bytes\n"**

that is my mysql version and characterset:

mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.6.36, for linux-glibc2.5 (x86_64) using  EditLine wrapper

Connection id:		13
Current database:	grafana
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		5.6.36 MySQL Community Server (GPL)
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8
Db     characterset:	utf8
Client characterset:	utf8
Conn.  characterset:	utf8
UNIX socket:		/var/lib/mysql/mysql.sock
Uptime:			6 min 37 sec

and that is dashboard table schema:

mysql> desc dashboard;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| id         | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| version    | int(11)      | NO   |     | NULL    |                |
| slug       | varchar(189) | NO   |     | NULL    |                |
| title      | varchar(255) | NO   |     | NULL    |                |
| data       | mediumtext   | YES  |     | NULL    |                |
| org_id     | bigint(20)   | NO   | MUL | NULL    |                |
| created    | datetime     | NO   |     | NULL    |                |
| updated    | datetime     | NO   |     | NULL    |                |
| updated_by | int(11)      | YES  |     | NULL    |                |
| created_by | int(11)      | YES  |     | NULL    |                |
| gnet_id    | bigint(20)   | YES  | MUL | NULL    |                |
| plugin_id  | varchar(255) | YES  |     | NULL    |                |
+------------+--------------+------+-----+---------+----------------+

it seems like the cloumn “plugin_id” data type is too long. I have modify the engine to myisam,but got that error

bin/grafana-server 
INFO[06-20|13:12:12] Starting Grafana                         logger=main version=4.3.2 commit=ed4d170 compiled=2017-05-31T16:48:16+0800
INFO[06-20|13:12:12] Config loaded from                       logger=settings file=/root/software/grafana-4.3.2/conf/defaults.ini
INFO[06-20|13:12:12] Path Home                                logger=settings path=/root/software/grafana-4.3.2
INFO[06-20|13:12:12] Path Data                                logger=settings path=/root/software/grafana-4.3.2/data
INFO[06-20|13:12:12] Path Logs                                logger=settings path=/root/software/grafana-4.3.2/data/log
INFO[06-20|13:12:12] Path Plugins                             logger=settings path=/root/software/grafana-4.3.2/data/plugins
INFO[06-20|13:12:12] Initializing DB                          logger=sqlstore dbtype=mysql
INFO[06-20|13:12:12] Starting DB migration                    logger=migrator
INFO[06-20|13:12:12] Executing migration                      logger=migrator id="copy data account to org"
INFO[06-20|13:12:12] Skipping migration condition not fulfilled logger=migrator id="copy data account to org"
INFO[06-20|13:12:12] Executing migration                      logger=migrator id="copy data account_user to org_user"
INFO[06-20|13:12:12] Skipping migration condition not fulfilled logger=migrator id="copy data account_user to org_user"
INFO[06-20|13:12:12] Executing migration                      logger=migrator id="Add index for plugin_id in dashboard"
EROR[06-20|13:12:12] Executing migration failed               logger=migrator id="Add index for plugin_id in dashboard" error="Error 1071: Specified key was too long; max key length is 1000 bytes"
EROR[06-20|13:12:12] Exec failed                              logger=migrator error="Error 1071: Specified key was too long; max key length is 1000 bytes" sql="CREATE INDEX `IDX_dashboard_org_id_plugin_id` ON `dashboard` (`org_id`,`plugin_id`);"
EROR**[06-20|13:12:12] Fail to initialize orm engine            logger=sqlstore error="Sqlstore::Migration failed err: **Error 1071: Specified key was too long; max key length is 1000 bytes\n"

Looks like this issue: https://github.com/grafana/grafana/issues/8450

It is fixed in master: https://github.com/grafana/grafana/pull/8507 so you can either use the nightly build, rollback to an earlier version of Grafana or manually do the same fix in the table schema.

This fix will be in the next release in a week or two.