1.mysql errors:message from server: "Host 'xxx' is blocked because of many connection errors; unblockmysql
數據庫鏈接拋了異常:null, message from server: "Host 'PC-20130201IBXI' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"。linux
緣由:同一個ip在短期內產生太多(超過mysql數據庫max_connection_errors的最大值)中斷的數據庫鏈接而致使的阻塞;解決辦法以下:sql
mysqladmin -u root -p flush-hosts數據庫
2. MySQL 5.7.17 安裝報錯CMake Error at cmake/boost.cmake:81 (MESSAGE)vim
解決辦法是:
1).在/usr/local下建立一個名爲boost的文件夾
mkdir -p /usr/local/boost
2).進入這個新建立的文件夾而後下載boost
wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
3).解壓
tar -xvzf boost_1_59_0.tar.gz
4).繼續cmake,添加上紅色部分
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPILATION_COMMENT='Mysqlma' \
-DWITH_READLINE=ON \
-DWITH_BOOST=/usr/local/boost \
-DSYSCONFDIR=/data/mysqldata/3306 \
-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock安全
3.Mysql重啓失敗緣由剖析一服務器
Timeout error occurred trying to start MySQL Daemon.網絡
當修改完某些配置以後,打算/etc/init.d/mysqld restart,發現重啓失敗。less
首先看mysql的日誌文件查找緣由:tail /var/log/mysqld.logdom
發現爲用戶權限問題:
120724 15:52:02 [ERROR] /usr/libexec/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13)
120724 15:52:02 [ERROR] Can't start server: can't create PID file: Permission denied
120724 15:52:02 mysqld ended
========
solution
========
cd /var/lib/
ls -l | grep mysqld
看看用戶名和用戶組是否均爲mysql,若是不是,則從新將權限調整回mysql默認值。
chown -R mysql:mysql mysqld
chmod 755 -R mysqld
如今試試重啓服務:/etc/init.d/mysqld start
若是重啓仍失敗,則還有多是執行文件的權限還有問題:
cd /var/run/
ls -l | grep mysqld
看看用戶名和用戶組是否均爲mysql,若是不是,則從新將權限調整回mysql默認值。
chown -R mysql:mysql mysqld
4.mysql數據庫經過yum安裝後啓動不了。以下:
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
查看日誌
[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
輸入mysql_install_db命令後,重啓mysql成功。
[root@localhost etc]# mysql_install_db
Installing MySQL system tables...
[root@localhost etc]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
5.一次mysql slave故障的解決過程
mysql> show slave status\G
Last_SQL_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master’s binary log is corrupted (you can check this by running ‘mysqlbinlog’ on the binary log), the slave’s relay log is corrupted (you can check this by running ‘mysqlbinlog’ on the relay log), a network problem, or a bug in the master’s or slave’s MySQL code. If you want to check the master’s binary log or slave’s relay log, you will be able to know their names by issuing ‘SHOW SLAVE STATUS’ on this slave. Error_code: 1594
看樣子,應該因爲網絡緣由 slave relay log損壞了
查看 mysql 日誌:
170306 12:34:08 [Note] Slave SQL thread initialized, starting replication in log ‘mysql-bin.000033’ at position 77270703, relay log ‘./HK3ASERVER-relay-bin.066281’ position: 10604437
170306 12:34:08 [ERROR] Error in Log_event::read_log_event(): ‘read error’, data_len: 67, event_type: 19
170306 12:34:08 [ERROR] Error reading relay log event: slave SQL thread aborted because of I/O error
170306 12:34:08 [ERROR] Slave SQL: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master’s binary log is corrupted (you can check this by running ‘mysqlbinlog’ on the binary log), the slave’s relay log is corrupted (you can check this by running ‘mysqlbinlog’ on the relay log), a network problem, or a bug in the master’s or slave’s MySQL code. If you want to check the master’s binary log or slave’s relay log, you will be able to know their names by issuing ‘SHOW SLAVE STATUS’ on this slave. Error_code: 1594
170306 12:34:08 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with 「SLAVE START」. We stopped at log ‘mysql-bin.000033’ position 77270703
mysql> stop slave;
mysql> change master to Master_Log_File=’mysql-bin.000033’, Master_Log_Pos=77270703;
This operation cannot be performed with a running slave; run STOP SLAVE first
mysql> show slave status\G
發現IO_THREAD線程一直存在停不掉
最後,將mysql/data目錄下的 master.info 備走,從新啓動 mysql
mysql> show slave status\G
發現 slave 已完全停掉了
mysql> reset slave;
mysql> change master to Master_Log_File=’mysql-bin.000033’, Master_Log_Pos=77270703;
mysql> start slave;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
slave 恢復正常
6.主從複製或主主複製時發生以下狀況
Slave_IO_Running: Connecting
緣由
1)網絡不通
2)pos位置不對
3)repl密碼不對
4) 防火牆規則阻攔或者selinux沒關
5) server-id不對
7.mysql啓動失敗報錯之一
[ERROR] Can't create interrupt-thread (error 11, errno: 11)
或
Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug'
或
InnoDB: Error: pthread_create returned 11
1.)直接處理方法,重啓服務器,刷新進程鏈接。
2.)修改max user processes
ulimit -u 查看
修改/etc/security/limits.conf文件,添加:
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535 增長max user processes
* hard nproc 65535
查看/etc/security/limits.d目錄是否有文件「90-nproc.conf」,沒有的話新建該文件,文件,內容寫爲:
* soft nproc 65535
* hard nproc 65535
退出(logout)從新登陸後,使用ulimit -a查看系統參數
8.ERROR! The server quit without updating PID file (/usr/local/mysql/var/LNMP.pid)之一
[root@LNMP ~]# /etc/init.d/mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/var/LNMP.pid).
9.Starting MySQL...The server quit without updating PID file 之二
1) 問題
[root@localhost mysql]# /etc/rc.d/init.d/mysql status
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]
[root@localhost mysql]# /etc/rc.d/init.d/mysql start
Starting MySQL...The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid). [FAILED]
2 )緣由
沒有初始化權限表
3 )解決辦法
#cd /usr/local/mysql(進入mysql安裝目錄)
#chown -R mysql.mysql .
#su - mysql
$cd server
$scripts/mysql_install_db
4 )解決過程
[root@localhost ~]# cd /usr/local/mysql
[root@localhost mysql]# chown -R mysql.mysql .
[root@localhost mysql]# su - mysql
[mysql@localhost ~]$ cd /usr/local/mysql
[mysql@localhost mysql]$ scripts/mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
[mysql@localhost mysql]$ /usr/local/mysql/bin/mysqld_safe --user=mysql &
[1] 11767
[mysql@localhost mysql]$ 120502 07:01:17 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
120502 07:01:17 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql status
MySQL running (11830) [ OK ]
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql start
Starting MySQL [ OK ]
10.Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid)之三
原由:在VM 上將一數據庫的數據文件(/var/lib/mysql整個文件夾)拷貝到另一臺VM上,而後新的VM 上啓動MYSQL,結果報以下異常:(提示:冷備務必保證關閉服務)
[root@localhost mysql]# service mysql start
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
大部分的答案都是:
1). 註釋/etc/my.cnf裏的skip-federated註釋掉即#skip-federated;
2). my.cnf文件配置太高,從新定義其中的參數(根據服務器狀況定義);
3). 殺掉mysql_safe和mysqld進程,而後再重啓;
4). 當前日誌文件過大,超出了my.cnf中定義的大小(默認爲64M),刪除日誌文件再重啓;
5). 其餘狀況,查看日誌文件(個人是localhost.localdomain.err,具體因人而異),而後具體分析;
問題解決:
其中,查看了日誌內容,以下:
[root@localhost mysql]# less localhost.localdomain.err
111203 22:09:03 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
^G/usr/sbin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
111203 22:09:03 [ERROR] Aborting
111203 22:09:03 [Note] /usr/sbin/mysqld: Shutdown complete
111203 22:09:03 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended
可是我查看了個人目錄文件,mysql-bin.index文件是存在的呀,奇怪:
[root@localhost mysql]# ll
total 49828
-rw-rw----. 1 mysql mysql 35651584 Dec 3 17:55 ibdata1
-rw-rw----. 1 mysql mysql 5242880 Dec 3 17:55 ib_logfile0
-rw-rw----. 1 mysql mysql 5242880 Dec 3 15:45 ib_logfile1
-rw-rw----. 1 mysql root 1376 Dec 3 22:02 localhost.localdomain.err
drwx--x--x. 2 mysql mysql 4096 Dec 3 17:55 mysql
-rw-rw----. 1 mysql mysql 4847020 Dec 3 17:55 mysql-bin.000001
-rw-rw----. 1 mysql mysql 1373 Dec 3 17:56 mysql-bin.000002
-rw-r--r--. 1 root root 19 Dec 3 15:38 mysql-bin.index
drwx------. 2 mysql mysql 4096 Dec 3 17:55 performance_schema
-rw-r--r--. 1 root root 116 Nov 25 21:03 RPM_UPGRADE_HISTORY
-rw-r--r--. 1 mysql mysql 116 Nov 25 21:03 RPM_UPGRADE_MARKER-LAST
drwxr-xr-x. 2 mysql mysql 4096 Dec 3 17:55 test
仔細看了下,咦?-rw-r--r--. 1 root root 19 Dec 3 15:38 mysql-bin.index----難道是權限不夠?因而將該文件加了寫權限,重啓,濤聲依舊!!!噢噢!
難道是編碼問題?難道是....繼續猜想。。。問題仍是沒解決,後來我作了一件事情,將mysql-bin.index文件刪除掉!或者修改其全部者全部組,重啓!
[root@localhost mysql]# rm -rf mysql-bin.index
[root@localhost mysql]#
[root@localhost mysql]# service mysql start
Starting MySQL... SUCCESS!
補充:
不少時候,咱們在作主從同步的時候,將數據庫目錄總體打包拷貝到從機上的時候,重啓也每每會出現相似的問題,解決方法仍然是:
1)給MYSQL數據庫數據目錄權限:chown -R mysql:mysql 目錄名稱
2)務必保證MYSQL的進程是已經關閉了的;
另外要注意的地方就是:ib_*, mysql-bin-*, *.err(log文件)以及master-info和relay-info文件都是能夠刪除的,至關於從新初始化數據庫的數據,可是前提是:
1)操做前要先關掉MYSQL的進程;
2)刪掉文件後要從新啓動MYSQL,若是有異常,請自行查看日誌找問題,通常都比較好定位和解決。
11.The server quit without updating PID file (/var/lib/mysql/tserver.pid).[FAILED] 之四
查看日誌
[ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
[ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting
解決辦法:
刪除了以下三個文件:
[root@tserver mysql]# rm ibdata1 ib_logfile0 ib_logfile1
rm: remove regular file `ibdata1'? yes
rm: remove regular file `ib_logfile0'? yes
rm: remove regular file `ib_logfile1'? yes
重啓 OK
12.啓動報錯 Neither host 'localhost.localdomain' nor 'localhost' could be looked up with...
解決方法:
查看cat /etc/hosts 發現什麼文件也沒有,編輯內容相關配置。
vim /etc/hosts 輸入如下內容:127.0.0.1localhost.localdomain localhost
重啓 OK
13.在執行scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldb
命令時一直報錯:
Can't locate Data/Dumper.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .)
at scripts/mysql_install_db line 42. BEGIN failed--compilation aborted at scripts/mysql_install_db line 42.
緣由:
Fedora 19中yum的prel包中沒有Dumper.pm文件。這時候只要執行如下命令就能夠手動下載Dumper.pm文件
yum install 'perl(Data::Dumper)'
14.手動刪除binlog日誌後啓動失敗,報錯以下:
Failed to open log (file './mysql-bin.000002', errno 2)
2018-01-16 13:59:13 4084 [ERROR] Could not open log file
2018-01-16 13:59:13 4084 [ERROR] Can't init tc log
解決辦法:刪除binlog索引文件
rm -rf mysql-bin.index
而後重啓便可
15.CentOS7.2默認安裝mariadb-server
報錯:Failed to start mysqld.service: Unit not
found
當輸入命令
~]# systemctl start mysql.service
要啓動MySQL數據庫是倒是這樣的提示
Failed to start mysqld.service: Unit not found
緣由:
CentOS 7的yum源中貌似沒有正常安裝mysql時的mysql-sever文件,須要去官網上下載
解決方法以下:
方法一:(經常使用+實用)
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
service mysqld start
方法二:
首先須要安裝mariadb-server
~]# yum install -y mariadb-server
啓動服務
~]# systemctl start mariadb.service
添加到開機啓動
~]# systemctl enable mariadb.service
進行一些安全設置,以及修改數據庫管理員密碼
~]# mysql_sceure_installation
至此完成!
能夠測試一下
~]# mysql -u root -p
後續積累中....