一次非法关机导致mysql数据表损坏的实例解决_MySQL
bitsCN.com
排查修复数据表的经过:
1、访问网页,提示错误,连接不到数据库。
2、启动mysql服务,卸载和关闭rpm安装的mysql服务
(昨天安装postfix好像yum安装了mysql),用netstat -anp |grep mysqld 命令查看mysql服务没有起来,用mysql -uroot -p也连接不到服务器。
3、查看错误提示:
110726 17:02:23 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110726 17:02:23 [ERROR] /usr/local/mysql/libexec/mysqld: Table './mysql/host' is marked as crashed and last (automatic?) repair failed
110726 17:02:23 [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/host' is marked as crashed and last (automatic?) repair failed 110726 17:02:23 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended
110726 17:24:31 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
110726 17:24:31 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
发现提示数据库表损坏。(./mysql/host)
4、修复数据库表:
cd /var/lib/mysql/mysql
myisamchk -of host.MYI
- recovering (with keycache) MyISAM-table 'host.MYI'
Data records: 0
表host.MYI修复成功。
5、再次启动服务,查看服务是否启动,登录mysql,还是不行。所以再次查看错误日志。
/usr/local/mysql/libexec/mysqld: Table './mysql/plugin' is marked as crashed and last (automatic?) repair failed
/usr/local/mysql/libexec/mysqld: Table 'plugin' is marked as crashed and last (automatic?) repair failed
110726 17:24:31 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110726 17:24:31 [ERROR] /usr/local/mysql/libexec/mysqld: Table './mysql/user' is marked as crashed and last (automatic?) repair failed
110726 17:24:31 [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/user' is marked as crashed and last (automatic?) repair failed 110726 17:24:31 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended
110726 17:27:13 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
110726 17:27:13 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
6、又发现./mysql/user表损坏。
[root@localhost mysql]# myisamchk -of user.MYI
- recovering (with keycache) MyISAM-table 'user.MYI'
Data records: 6
7、表修复成功,但是还是启动不了服务,继续看错误日志。
/usr/local/mysql/libexec/mysqld: Table './mysql/plugin' is marked as crashed and last (automatic?) repair failed
/usr/local/mysql/libexec/mysqld: Table 'plugin' is marked as crashed and last (automatic?) repair failed
110726 17:27:13 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110726 17:27:13 [ERROR] /usr/local/mysql/libexec/mysqld: Table './mysql/db' is marked as crashed and last (automatic?) repair failed
110726 17:27:13 [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/db' is marked as crashed and last (automatic?) repair failed
110726 17:27:13 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended
8、最后一个错误,是./mysql/db表还没有修复好继续修复./mysql/db表。
9、执行下面的命令修复./mysql/db表:
[root@localhost mysql]# myisamchk -of db.MYI
- recovering (with keycache) MyISAM-table 'db.MYI'
Data records: 0
Data records: 2
10、最后启动mysql服务。
/usr/local/mysql/bin/mysqld_safe &
11、查看服务是否在运行。
[root@localhost ~]# netstat -anp | grep mysqld
tcp0 0
0.0.0.0:3306
0.0.0.0:* LISTEN
4360/mysqld
unix 2 [ ACC ] STREAM LISTENING 14172
4360/mysqld /tmp/mysql.sock
这时发现服务已运行。
12、登录mysql试试。
[root@localhost ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 35
Server version: 5.1.55-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql>
可以登录。
13、打开网页,已经可以正常访问了,说明MySQL数据库的数据表修复成功。
bitsCN.com
핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제









AppleID를 사용하여 iTunesStore에 로그인하면 "이 AppleID는 iTunesStore에서 사용되지 않았습니다"라는 오류가 화면에 표시될 수 있습니다. 걱정할 오류 메시지는 없습니다. 다음 솔루션 세트에 따라 문제를 해결할 수 있습니다. 수정 1 – 배송 주소 변경 iTunes Store에 이 메시지가 나타나는 주된 이유는 AppleID 프로필에 올바른 주소가 없기 때문입니다. 1단계 – 먼저 iPhone에서 iPhone 설정을 엽니다. 2단계 – AppleID는 다른 모든 설정보다 우선해야 합니다. 그러니 열어보세요. 3단계 – 거기에서 “결제 및 배송” 옵션을 엽니다. 4단계 – Face ID를 사용하여 액세스 권한을 확인하세요. 단계

PHP에서 MySQL 데이터베이스를 백업하고 복원하는 작업은 다음 단계에 따라 수행할 수 있습니다. 데이터베이스 백업: mysqldump 명령을 사용하여 데이터베이스를 SQL 파일로 덤프합니다. 데이터베이스 복원: mysql 명령을 사용하여 SQL 파일에서 데이터베이스를 복원합니다.

선형 복잡성에서 로그 복잡성까지 조회 시간을 줄이는 인덱스를 구축하여 MySQL 쿼리 성능을 최적화할 수 있습니다. SQL 삽입을 방지하고 쿼리 성능을 향상하려면 PREPAREDStatements를 사용하세요. 쿼리 결과를 제한하고 서버에서 처리되는 데이터의 양을 줄입니다. 적절한 조인 유형 사용, 인덱스 생성, 하위 쿼리 사용 고려 등 조인 쿼리를 최적화합니다. 쿼리를 분석하여 병목 현상을 식별하고, 캐싱을 사용하여 데이터베이스 로드를 줄이고, 오버헤드를 최소화합니다.

비행기 모드는 어떤 상황에서는 매우 편리합니다. 그러나 동일한 비행기 모드로 인해 iPhone이 갑자기 멈추면 두통이 생길 수 있습니다. 이 기사에서는 iPhone을 비행기 모드에서 해제하는 솔루션 세트를 설계했습니다. 빠른 수정 - 1. 제어 센터에서 직접 비행기 모드를 비활성화해 보세요. 2. 제어 센터에서 비행기 모드를 비활성화할 수 없는 경우 설정 탭에서 직접 비행기 모드를 비활성화할 수 있습니다. 이러한 팁이 작동하지 않으면 아래 수정 사항에 따라 문제를 해결하십시오. 수정 1 – 장치를 강제로 다시 시작 장치를 강제로 다시 시작하는 과정은 매우 간단합니다. 당신이 해야 할 일은 다음의 단계별 지침을 따르는 것 뿐입니다. 1단계 – 볼륨 크게 버튼을 눌렀다 놓아 프로세스를 시작할 수 있습니다. 단계

PHP를 사용하여 MySQL 테이블을 생성하려면 다음 단계가 필요합니다. 데이터베이스에 연결합니다. 데이터베이스가 없으면 작성하십시오. 데이터베이스를 선택합니다. 테이블을 생성합니다. 쿼리를 실행합니다. 연결을 닫습니다.

MySQL 8.4(2024년 최신 LTS 릴리스)에 도입된 주요 변경 사항 중 하나는 "MySQL 기본 비밀번호" 플러그인이 더 이상 기본적으로 활성화되지 않는다는 것입니다. 또한 MySQL 9.0에서는 이 플러그인을 완전히 제거합니다. 이 변경 사항은 PHP 및 기타 앱에 영향을 미칩니다.

Apple의 최신 iOS18, iPadOS18 및 macOS Sequoia 시스템 릴리스에는 사진 애플리케이션에 중요한 기능이 추가되었습니다. 이 기능은 사용자가 다양한 이유로 손실되거나 손상된 사진과 비디오를 쉽게 복구할 수 있도록 설계되었습니다. 새로운 기능에는 사진 앱의 도구 섹션에 '복구됨'이라는 앨범이 도입되었습니다. 이 앨범은 사용자가 기기에 사진 라이브러리에 포함되지 않은 사진이나 비디오를 가지고 있을 때 자동으로 나타납니다. "복구된" 앨범의 출현은 데이터베이스 손상으로 인해 손실된 사진과 비디오, 사진 라이브러리에 올바르게 저장되지 않은 카메라 응용 프로그램 또는 사진 라이브러리를 관리하는 타사 응용 프로그램에 대한 솔루션을 제공합니다. 사용자는 몇 가지 간단한 단계만 거치면 됩니다.

MySQLi를 사용하여 PHP에서 데이터베이스 연결을 설정하는 방법: MySQLi 확장 포함(require_once) 연결 함수 생성(functionconnect_to_db) 연결 함수 호출($conn=connect_to_db()) 쿼리 실행($result=$conn->query()) 닫기 연결( $conn->close())
