如何更改phpmyadmin中的默认存储引擎?


28

我几乎只在应用程序中使用InnoDB。但是,如果我在设置表时不小心,则会忘记更改它,而phpmyadmin会坚持使用MyISAM。有没有办法更改默认存储引擎?


也许与PHPMyAdmin无关,而与MySQL直接相关。你有没有试过这样: - stackoverflow.com/questions/2286813/...
塞巴斯蒂安·罗斯

2
通过执行以下步骤是可能的:导航到> phpmyadmin->更多->变量->存储引擎,并将其MyISAM更改为InnoDB。

@ user21380:在这里您只能看到MySQL正在使用的引擎。
machineaddict

Answers:


21

您必须default-storage-engine = InnoDB[mysqld]mysql配置文件(取决于操作系统,my.cnf或my.ini)的部分下添加该行,然后重新启动mysqld服务。

我不相信您可以通过PhpMyAdmin更改此设置。



1

这个答案有点晚了,但可能会对其他人有所帮助。如果您担心在MySQL服务器上弄乱某些内容,则可以从phpMyAdmin创建表时更改默认引擎。为MySQL引擎的默认选择创建者在此功能下StorageEngine.class.phplibraries文件夹(在phpMyAdmin 3.5.8.2):

<?php
/**
 * returns HTML code for storage engine select box
 *
 * @param string  $name                    The name of the select form element
 * @param string  $id                      The ID of the form field
 * @param string  $selected                The selected engine
 * @param boolean $offerUnavailableEngines Should unavailable storage engines be offered?
 *
 * @static
 * @return  string  html selectbox
 */
static public function getHtmlSelect($name = 'engine', $id = null,
  $selected = null, $offerUnavailableEngines = false)
{
    $selected   = strtolower($selected);
    $output     = '<select name="' . $name . '"'
        . (empty($id) ? '' : ' id="' . $id . '"') . '>' . "\n";

    foreach (PMA_StorageEngine::getStorageEngines() as $key => $details) {
        // Don't show PERFORMANCE_SCHEMA engine (MySQL 5.5)
        // Don't show MyISAM for Drizzle (allowed only for temporary tables)
        if (! $offerUnavailableEngines
            && ($details['Support'] == 'NO'
            || $details['Support'] == 'DISABLED'
            || $details['Engine'] == 'PERFORMANCE_SCHEMA')
            || (PMA_DRIZZLE && $details['Engine'] == 'MyISAM')
        ) {
            continue;
        }

        $output .= '    <option value="' . htmlspecialchars($key). '"'
            . (empty($details['Comment'])
                ? '' : ' title="' . htmlspecialchars($details['Comment']) . '"')
            . (strtolower($key) == $selected || (empty($selected) && $details['Support'] == 'DEFAULT')
                ? ' selected="selected"' : '') . '>' . "\n"
            . '        ' . htmlspecialchars($details['Engine']) . "\n"
            . '    </option>' . "\n";
    }
    $output .= '</select>' . "\n";
    return $output;
}

从以下查询中填充此选择:

SHOW STORAGE ENGINES

以下代码选择了MySQL配置文件设置的默认引擎:

(empty($selected) && $details['Support'] == 'DEFAULT')

但是,我们可以对其进行更改以使其选择InnoDB作为默认引擎:

(empty($selected) && $details['Engine'] == 'InnoDB')
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.