我试图弄清楚如何在数据库中定位一个url的所有事件。我想搜索所有表和所有字段。但我不知道从哪里开始,甚至不知道是否有可能。


当前回答

SQLyog是基于GUI的解决方案,可以跨所有列、表和数据库进行数据搜索。用户可以自定义搜索,将其限制为字段、表和数据库。

在它的数据搜索功能中,用户可以像使用谷歌一样搜索字符串。

其他回答

您可以通过使用HeidiSQL而不生成Db转储来实现这一点

步骤:

1)在GUI左侧面板中选择需要搜索的数据库。

2)导出>导出数据库为SQL

3)在表格工具窗口中选择“查找文本”选项卡。

4)提供你的字符串进行搜索,然后点击“FIND”。

5)它将列出所有包含我们字符串的表。

6)选择相关度%较高的行。

7)点击“查看结果”

我正在寻找相同的,但找不到它,所以我在PHP中做了一个小脚本,你可以在: http://tequilaphp.wordpress.com/2010/07/05/searching-strings-in-a-database-and-files/

好运! (我删除了一些私人代码,如果我没有在这个过程中破坏它,请告诉我:D)

在phpMyAdmin的搜索功能是可用的:

选择特定的数据库而不是表。 点击“搜索”标签 输入你想要的搜索词 选择要搜索的表

phpMyAdmin屏幕截图:

'Search'特性也可以在MySQL Workbench中使用:

数据库菜单>查询表数据 选择要搜索的数据库和表(只会在选定的表中搜索) 在搜索中你可以使用wildChars。

MySQL Workbench屏幕截图:

使用MySQL Workbench,您可以从"Database" -> " search Table Data"菜单选项中搜索字符串。

指定LIKE %URL_TO_SEARCH%,并在左侧选择要搜索的所有表。您可以使用“Cntrl + A”选择左侧的整个树,然后取消选择您不关心的对象。

当我们在Wordpress网站上更改域名时,我自己也在寻找这个。没有编程是做不到的,这就是我所做的。

<?php  
  header("Content-Type: text/plain");

  $host = "localhost";
  $username = "root";
  $password = "";
  $database = "mydatabase";
  $string_to_replace  = 'old.example.com';
  $new_string = 'new.example.com';

  // Connect to database server
  mysql_connect($host, $username, $password);

  // Select database
  mysql_select_db($database);

  // List all tables in database
  $sql = "SHOW TABLES FROM ".$database;
  $tables_result = mysql_query($sql);

  if (!$tables_result) {
    echo "Database error, could not list tables\nMySQL error: " . mysql_error();
    exit;
  }

  echo "In these fields '$string_to_replace' have been replaced with '$new_string'\n\n";
  while ($table = mysql_fetch_row($tables_result)) {
    echo "Table: {$table[0]}\n";
    $fields_result = mysql_query("SHOW COLUMNS FROM ".$table[0]);
    if (!$fields_result) {
      echo 'Could not run query: ' . mysql_error();
      exit;
    }
    if (mysql_num_rows($fields_result) > 0) {
      while ($field = mysql_fetch_assoc($fields_result)) {
        if (stripos($field['Type'], "VARCHAR") !== false || stripos($field['Type'], "TEXT") !== false) {
          echo "  ".$field['Field']."\n";
          $sql = "UPDATE ".$table[0]." SET ".$field['Field']." = replace(".$field['Field'].", '$string_to_replace', '$new_string')";
          mysql_query($sql);
        }
      }
      echo "\n";
    }
  }

  mysql_free_result($tables_result);  
?>

希望它能帮助任何在未来遇到这个问题的人:)