本文目錄一覽:
- 1、這句話什麼意思?求解!是改密碼的時候出現的…英語翻譯
- 2、Linux下設置vsftpd虛擬賬號輸入密碼出現530錯誤
- 3、ubuntu下如何配置FTP
- 4、資料庫mysql創建表格老是出錯,看不懂英文提示?
這句話什麼意思?求解!是改密碼的時候出現的…英語翻譯
大意是你需要一個更複雜的密碼,比如說把短語的單詞加在一起,或鏈接每個單詞的首字母。大概是讓你把字母加到密碼里
。原意:需要一個更複雜的密碼,這個可以通過很多方式實現,比如說,把短語的單詞加在一起,或鏈接每個單詞的首字母
你的密碼必須不超過三個連續相同的字元
Linux下設置vsftpd虛擬賬號輸入密碼出現530錯誤
方法一:
登錄出現 vsftpd 530 login incorrect 報錯。
解決方法:
cp Path/RedHat/vsftpd.pam /etc/pam.d/ftp
path為vsftp解壓縮源文件目錄
這是因為我們RHEL啟用了PAM,所在用到vsftp時需要用到 /etc/pam.d/ftp這個文件(默認源碼安裝的不會有這個文件),因此除了匿名用戶外本地用戶無法登錄。
方法二:
在測試Checkpoint的VPN1 R6x的時候,遇到了這個錯誤。這說明client端跟server端的連接性是沒問題。但是就是想不出為什麼,還以為是用戶名和口令錯誤呢。後來才google了一下,發現是server端的配置有問題。
檢查/etc/vsftpd/user_list和/etc/ftpusers,是這個文件/etc/vsftpd/vsftpd.conf少了一行:
複製代碼
代碼如下:
pam_service_name=vsftpd
$ echo 『pam_service_name=vsftpd』 /etc/vsftpd/vsftpd.conf
$ service vsftpd restart
530 error就消除了!
下面是更詳細的方法:
[root@atr-3-server1 admin]# cat /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd’s
# capabilities.
#
# Allow anonymous FTP? (Beware – allowed by default if you comment this out).
anonymous_enable=no
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd’s)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages – messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using “root” for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that turning on ascii_download_enable enables malicious remote parties
# to consume your I/O resources, by issuing the command “SIZE /big/file” in
# ASCII mode.
# These ASCII options are split into upload and download because you may wish
# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
# on the client anyway..
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the “-R” option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as “ncftp” and “mirror” assume
# the presence of the “-R” option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
pam_service_name=vsftpd
userlist_enable=YES
#enable for standalone mode
listen=YES
tcp_wrappers=YES
具體你也可以去看下這裡有更詳細的操作方法希望可以幫到你啊
ubuntu下如何配置FTP
一.vsftpd說明:
LINUX下實現FTP服務的軟體很多,最常見的有vsftpd,Wu-ftpd和Proftp等.Red Hat Enterprise Linux中默認安裝的是vsftpd.
訪問FTP伺服器時需要經過驗證,只有經過了FTP伺服器的相關驗證,用戶才能訪問和傳輸文件.vsftpd提供了3種ftp登錄形式:
(1)anonymous(匿名帳號)
使用anonymous是應用廣泛的一種FTP伺服器.如果用戶在FTP伺服器上沒有帳號,那麼用戶可以以anonymous為用戶名,以自己的電子郵件地址為密碼進行登錄.當匿名用戶登錄FTP伺服器後,其登錄目錄為匿名FTP伺服器的根目錄/var/ftp.為了減輕FTP伺服器的負載,一般情況下,應關閉匿名帳號的上傳功能.
(2)real(真實帳號)
real也稱為本地帳號,就是以真實的用戶名和密碼進行登錄,但前提條件是用戶在FTP伺服器上擁有自己的帳號.用真實帳號登錄後,其登錄的目錄為用戶自己的目錄,該目錄在系統建立帳號時系統就自動創建.
(3)guest(虛擬帳號)
如果用戶在FTP伺服器上擁有帳號,但此帳號只能用於文件傳輸服務,那麼該帳號就是guest,guest是真實帳號的一種形式,它們的不同之處在於,geust登錄FTP伺服器後,不能訪問除宿主目錄以外的內容.
二.FTP相關配置文件說明
其相關配置文件有/etc/vsftpd/vsftpd.conf, /etc/vsftpd.ftpusers, /etc/vsftpd.user_list,在配置FTP伺服器時,主要是修改這些文件中的相關語句.
1.vsftpd.conf文件說明
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd’s
# capabilities.
#
# Allow anonymous FTP? (Beware – allowed by default if you comment this out).
anonymous_enable=YES //是否允許anonymous登錄FTP伺服器,默認是允許的.
#
# Uncomment this to allow local users to log in.
local_enable=YES //是否允許本地用戶登錄FTP伺服器,默認是允許
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES //是否允許用戶具有在FTP伺服器文件中執行寫的許可權,默認是允許
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd’s)
local_umask=022 //設置本地用戶的文件生成掩碼為022,默認是077
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES //是否允許匿名賬戶在FTP伺服器中創建目錄
#
# Activate directory messages – messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES //激活目錄信息,當遠程用戶更改目錄時,將出現提示信息
#
# Activate logging of uploads/downloads.
xferlog_enable=YES //啟用上傳和下載日誌功能
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES //啟用FTP數據埠的連接請求
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using “root” for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log //設置日誌文件的文件名和存儲路徑,這是默認的
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES//是否使用標準的ftpd xferlog日誌文件格式
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600 //設置空閑的用戶會話中斷時間,默認是10分鐘
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120//設置數據連接超時時間,默認是120秒.
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that turning on ascii_download_enable enables malicious remote parties
# to consume your I/O resources, by issuing the command “SIZE /big/file” in
# ASCII mode.
# These ASCII options are split into upload and download because you may wish
# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
# on the client anyway..
#ascii_upload_enable=YES
#ascii_download_enable=YES //是否允許使用ASCII格式來上傳和下載文件
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.//在FTP伺服器中設置歡迎登錄的信息.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES //如果希望用戶登錄後不能切換到自己目錄以外的其它目錄,需要設置該項,如果設置chroot_list_enable=YES,那麼只允許/etc/vsftpd.chroot_list中列出的用戶具有該功能.如果希望所有的本地用戶都執行者chroot,可以增加一行:chroot_local_user=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the “-R” option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as “ncftp” and “mirror” assume
# the presence of the “-R” option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
pam_service_name=vsftpd //設置PAM認證服務的配置文件名稱,該文件存放在/etc/pam.d/目錄下.
userlist_enable=YES //用戶列表中的用戶是否允許登錄FTP伺服器,默認是不允許
#enable for standalone mode
listen=YES //使vsftpd 處於獨立啟動模式
tcp_wrappers=YES //使用tcp_wrqppers作為主機訪問控制方式
2.vsftpd.ftpusers文件說明
這個文件是用來記錄”不允許”登錄到FTP伺服器的用戶,通常是一些系統默認的用戶.
下面是該文件中默認的不允許登錄的名單:
# Users that are not allowed to login via ftp
root //默認情況下,root和它以下的用戶是不允許登錄FTP伺服器的.可以將不允許登錄的用戶添加到這裡來.但切記每個用戶都要單獨佔用一行.
bin
daemon
adm
lp
sync
shutdown
halt
news
uucp
operator
games
nobody
3.vsftpd.user_list文件說明
其實它的內容跟上面那個文件內容一樣,只是在系統對文件vsftpd.conf 進行檢測時,會檢測到”userlist_deny=YES”,因此這個文件必須存在.下面是這個文件的內容.
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd.ftpusers
# for users that are denied.
root
bin
daemon
adm
lp
sync
shutdown
halt
news
uucp
operator
games
nobody
資料庫mysql創建表格老是出錯,看不懂英文提示?
來自:51CTO(作者:superZS)
我在剛開始學習資料庫的時候,沒少走彎路。經常會遇到各種稀奇古怪的 error 信息,遇到報錯會很慌張,急需一個解決問題的辦法。跟無頭蒼蠅一樣,會不加思索地把錯誤粘到百度上,希望趕緊查找一下有沒有好的處理問題的方法。我想這個應該是剛從事資料庫的小白,都會遇到窘境。
今天就給大家列舉 MySQL 資料庫中,最經典的十大錯誤案例,並附有處理問題的解決思路和方法,希望能給剛入行,或資料庫愛好者一些幫助,今後再遇到任何報錯,我們都可以很淡定地去處理。
學習任何一門技術的同時,其實就是自我修鍊的過程。沉下心,嘗試去擁抱數據的世界!
Top 1:
Too many connections(連接數過多,導致連接不上資料庫,業務無法正常進行)
問題還原
解決問題的思路:
1、首先先要考慮在我們 MySQL 資料庫參數文件裡面,對應的 max_connections 這個參數值是不是設置的太小了,導致客戶端連接數超過了資料庫所承受的最大值。
● 該值默認大小是151,我們可以根據實際情況進行調整。
● 對應解決辦法:set global max_connections=500
但這樣調整會有隱患,因為我們無法確認資料庫是否可以承擔這麼大的連接壓力,就好比原來一個人只能吃一個饅頭,但現在卻非要讓他吃 10 個,他肯定接受不了。反應到伺服器上面,就有可能會出現宕機的可能。
所以這又反應出了,我們在新上線一個業務系統的時候,要做好壓力測試。保證後期對資料庫進行優化調整。
2、其次可以限制 Innodb 的並發處理數量,如果 innodb_thread_concurrency = 0(這種代表不受限制) 可以先改成 16或是64 看伺服器壓力。如果非常大,可以先改的小一點讓伺服器的壓力下來之後,然後再慢慢增大,根據自己的業務而定。個人建議可以先調整為 16 即可。
MySQL 隨著連接數的增加性能是會下降的,可以讓開發配合設置 thread pool,連接復用。在MySQL商業版中加入了thread pool這項功能
另外對於有的監控程序會讀取 information_schema 下面的表,可以考慮關閉下面的參數
innodb_stats_on_metadata=0
set global innodb_stats_on_metadata=0
Top 2:(主從複製報錯類型)
Last_SQL_Errno: 1062 (從庫與主庫數據衝突)
Last_Errno: 1062
Last_Error: Could not execute Write_rows event on table test.t;
Duplicate entry ‘4’ for key ‘PRIMARY’,
Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY;
the event’s master log mysql-bin.000014, end_log_pos 1505
針對這個報錯,我們首先要考慮是不是在從庫中誤操作導致的。結果發現,我們在從庫中進行了一條針對有主鍵表的 sql 語句的插入,導致主庫再插入相同 sql 的時候,主從狀態出現異常。發生主鍵衝突的報錯。
解決方法:
在確保主從數據一致性的前提下,可以在從庫進行錯誤跳過。一般使用 percona-toolkit 中的 pt-slave-restart 進行。
在從庫完成如下操作
[root@zs bin]# ./pt-slave-restart -uroot -proot123
2017-07-20T14:05:30 p=…,u=root node4-relay-bin.000002 1506 1062
之後最好在從庫中開啟 read_only 參數,禁止在從庫進行寫入操作
Last_IO_Errno: 1593(server-id衝突)
Last_IO_Error:
Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids;
these ids must be different for replication to work
(or the –replicate-same-server-id option must be used on slave but this
does not always make sense; please check the manual before using it)
這個報錯出現之後,就看一目了然看到兩台機器的 server-id 是一樣的。
在搭建主從複製的過程中,我們要確保兩台機器的 server-id 是唯一的。這裡再強調一下 server-id 的命名規則(伺服器 ip 地址的最後一位+本 MySQL 服務的埠號)
解決方法:
在主從兩台機器上設置不同的 server-id。
Last_SQL_Errno: 1032(從庫少數據,主庫更新的時候,從庫報錯)
Last_SQL_Error:
Could not execute Update_rows event on table test.t; Can’t find record
in ‘t’, Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the
event’s master log mysql-bin.000014, end_log_pos 1708
解決問題的辦法:
根據報錯信息,我們可以獲取到報錯日誌和position號,然後就能找到主庫執行的哪條sql,導致的主從報錯。
在主庫執行:
/usr/local/mysql/bin/mysqlbinlog –no-defaults -v -v –base64-output=decode-rows /data/mysql/mysql-bin.000014 |grep -A 10 1708 1.log
cat 1.log
#170720 14:20:15 server id 3 end_log_pos 1708 CRC32 0x97b6bdec Update_rows: table id 113 flags: STMT_END_F
### UPDATE `test`.`t`
### WHERE
### @1=4 /* INT meta=0 nullable=0 is_null=0 */
### @2=’dd’ /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
### SET
### @1=4 /* INT meta=0 nullable=0 is_null=0 */
### @2=’ddd’ /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
# at 1708
#170720 14:20:15 server id 3 end_log_pos 1739 CRC32 0xecaf1922 Xid = 654
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
獲取到 sql 語句之後,就可以在從庫反向執行 sql 語句。把從庫缺少的 sql 語句補全,解決報錯信息。
在從庫依次執行:
mysql insert into t (b) values (‘ddd’);
Query OK, 1 row affected (0.01 sec)
mysql stop slave;
Query OK, 0 rows affected (0.00 sec)
mysql exit
Bye
[root@node4 bin]# ./pt-slave-restart -uroot -proot123
2017-07-20T14:31:37 p=…,u=root node4-relay-bin.000005 283 1032
Top 3:MySQL安裝過程中的報錯
[root@zs data]# /usr/local/mysql/bin/mysqld_safe –defaults-file=/etc/my.cnf [1] 3758
[root@zs data]# 170720 14:41:24 mysqld_safe Logging to ‘/data/mysql/error.log’.
170720 14:41:24 mysqld_safe Starting mysqld daemon with databases from /data/mysql170720
14:41:25 mysqld_safe mysqld from pid file /data/mysql/node4.pid ended
170720 14:41:24 mysqld_safe Starting mysqld daemon with databases from /data/mysql2017-07-20
14:41:25 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
Please use –explicit_defaults_for_timestamp server option
(see documentation for more details)./usr/local/mysql/bin/mysqld:
File ‘/data/mysql/mysql-bin.index’ not found (Errcode: 13 – Permission denied)
2017-07-20 14:41:25 4388 [ERROR] Aborting
解決思路:
遇到這樣的報錯信息,我們要學會時時去關注錯誤日誌 error log 裡面的內容。看見了關鍵的報錯點 Permission denied。證明當前 MySQL 資料庫的數據目錄沒有許可權。
解決方法:
[root@zs data]# chown mysql:mysql -R mysql
[root@zs data]# /usr/local/mysql/bin/mysqld_safe –defaults-file=/etc/my.cnf
[1] 4402
[root@zs data]# 170720 14:45:56 mysqld_safe Logging to ‘/data/mysql/error.log’.
170720 14:45:56 mysqld_safe Starting mysqld daemon with databases from /data/mysql
啟動成功。
如何避免這類問題,個人建議在安裝 MySQL 初始化的時候,一定加上–user=mysql,這樣就可以避免許可權問題。
./mysql_install_db –basedir=/usr/local/mysql/ –datadir=/data/mysql/ –defaults-file=/etc/my.cnf –user=mysql
Top 4:資料庫密碼忘記的問題
[root@zs ~]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
[root@zs ~]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
我們有可能剛剛接手別人的 MySQL 資料庫,而且沒有完善的交接文檔。root 密碼可以丟失或者忘記了。
解決思路:
目前是進入不了資料庫的情況,所以我們要考慮是不是可以跳過許可權。因為在資料庫中,mysql資料庫中user表記錄著我們用戶的信息。
解決方法:
啟動 MySQL 資料庫的過程中,可以這樣執行:
/usr/local/mysql/bin/mysqld_safe –defaults-file=/etc/my.cnf –skip-grant-tables
這樣啟動,就可以不用輸入密碼,直接進入 mysql 資料庫了。然後在修改你自己想要改的root密碼即可。
update mysql.user set password=password(‘root123′) where user=’root’;
Top 5:truncate 刪除數據,導致自動清空自增ID,前端返回報錯 not found。
這個問題的出現,就要考慮下 truncate 和 delete 的區別了。
看下實驗演練:
首先先創建一張表;
CREATE TABLE `t` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` varchar(20) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`)
) ENGINE=InnoDB AUTO_INCREMENT=300 DEFAULT CHARSET=utf8
插入三條數據:
mysql insert into t (b) values (‘aa’);
Query OK, 1 row affected (0.00 sec)
mysql insert into t (b) values (‘bb’);
Query OK, 1 row affected (0.00 sec)
mysql insert into t (b) values (‘cc’);
Query OK, 1 row affected (0.00 sec)
mysql select * from t;
+—–+——+
| a | b |
+—–+——+
| 300 | aa |
| 301 | bb |
| 302 | cc |
+—–+——+
3 rows in set (0.00 sec)
先用 delete 進行刪除全表信息,再插入新值。
結果發現 truncate 把自增初始值重置了,自增屬性從1開始記錄了。當前端用主鍵id進行查詢時,就會報沒有這條數據的錯誤。
個人建議不要使用 truncate 對錶進行刪除操作,雖然可以回收表空間,但是會涉及自增屬性問題。這些坑,我們不要輕易鑽進去。
Top 6:
阿里雲 MySQL 的配置文件中,需要注意一個參數設置就是:
lower_case_table_names = 0;默認情況
lower_case_table_names = 1;是不區分大小寫 . 如果報你小寫的表名找不到, 那你就把遠端資料庫的表名改成小寫 , 反之亦然 . 注意 Mybatis 的 Mapper 文件的所有表名也要相應修改
Top 7:
有同學經常會問張老師,為什麼我的資料庫總會出現中文亂碼的情況。一堆????不知道怎麼回事。當向資料庫中寫入創建表,並插入中文時,會出現這種問題。此報錯會涉及資料庫字符集的問題。
解決思路:
對於中文亂碼的情況,記住老師告訴你的三個統一就可以。還要知道在目前的mysql資料庫中字符集編碼都是默認的UTF8
處理辦法:
1、數據終端,也就是我們連接資料庫的工具設置為 utf8
2、操作系統層面;可以通過 cat /etc/sysconfig/i18n 查看;也要設置為 utf8
3、資料庫層面;在參數文件中的 mysqld 下,加入 character-set-server=utf8。
Emoji 表情符號錄入 mysql 資料庫中報錯。
Caused by: java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x98\x97\xF0\x9F…’ for column ‘CONTENT’ at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1379)
解決思路:針對錶情插入的問題,一定還是字符集的問題。
處理方法:我們可以直接在參數文件中,加入
vim /etc/my.cnf
[mysqld]
init-connect=’SET NAMES utf8mb4′
character-set-server=utf8mb4
註:utf8mb4 是 utf8 的超集。
Top 8:使用 binlog_format=statement 這種格式,跨庫操作,導致從庫丟失數據,用戶訪問導致出現錯誤數據信息。
當前資料庫二進位日誌的格式為:binlog_format=statement
在主庫設置binlog-do-db=mydb1(只同步mydb1這一個庫)
在主庫執行use mydb2;
insert into mydb1.t1 values (‘bb’);這條語句不會同步到從庫。
但是這樣操作就可以;
use mydb1;
insert into mydb1.t1 values (‘bb’);因為這是在同一個庫中完成的操作。
在生產環境中建議使用binlog的格式為row,而且慎用binlog-do-db參數。
Top 9:MySQL 資料庫連接超時的報錯 ;
org.hibernate.util.JDBCExceptionReporter – SQL Error:0, SQLState: 08S01
org.hibernate.util.JDBCExceptionReporter – The last packet successfully received from the server was43200 milliseconds ago.The last packet sent successfully to the server was 43200 milliseconds ago, which is longer than the server configured value of ‘wait_timeout’. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection ‘autoReconnect=true’ to avoid this problem.
org.hibernate.event.def.AbstractFlushingEventListener – Could not synchronize database state with session
org.hibernate.exception.JDBCConnectionException: Could not execute JDBC batch update
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
org.hibernate.util.JDBCExceptionReporter – SQL Error:0, SQLState: 08003
org.hibernate.util.JDBCExceptionReporter – No operations allowed after connection closed. Connection was implicitly closed due to underlying exception/error:
** BEGIN NESTED EXCEPTION **
大多數做 DBA 的同學,可能都會被開發人員告知,你們的資料庫報了這個錯誤了。趕緊看看是哪裡的問題。
這個問題是由兩個參數影響的,wait_timeout 和 interactive_timeout。數據默認的配置時間是28800(8小時)意味著,超過這個時間之後,MySQL 資料庫為了節省資源,就會在資料庫端斷開這個連接,Mysql伺服器端將其斷開了,但是我們的程序再次使用這個連接時沒有做任何判斷,所以就掛了。
解決思路:
先要了解這兩個參數的特性;這兩個參數必須同時設置,而且必須要保證值一致才可以。
我們可以適當加大這個值,8小時太長了,不適用於生產環境。因為一個連接長時間不工作,還佔用我們的連接數,會消耗我們的系統資源。
解決方法:
可以適當在程序中做判斷;強烈建議在操作結束時更改應用程序邏輯以正確關閉連接;然後設置一個比較合理的timeout的值(根據業務情況來判斷)
Top 10 :can’t open file (errno:24)
有的時候,資料庫跑得好好的,突然報不能打開資料庫文件的錯誤了。
解決思路:
首先我們要先查看資料庫的 error log。然後判斷是表損壞,還是許可權問題。還有可能磁碟空間不足導致的不能正常訪問表;操作系統的限制也要關注下;用 perror 工具查看具體錯誤!
linux:/usr/local/mysql/bin # ./perror 24
OS error code 24: Too many open files
超出最大打開文件數限制!ulimit -n查看系統的最大打開文件數是65535,不可能超出!那必然是資料庫的最大打開文件數超出限制!
在 MySQL 里查看最大打開文件數限制命令:show variables like ‘open_files_limit’;
發現該數值過小,改為2048,重啟 MySQL,應用正常
處理方法:
repair table ;
chown mysql許可權
清理磁碟中的垃圾數據
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/240212.html