mysql常用命令

[toc]

set env

db_host=136.198.111.110
db_password=db.3NIoTP7
db_port=3081
db_user=order
db_name=order_from
db_table=product

备份表

mysqldump -h${db_host} -u${db_user} -p${db_password} -P${db_port} ${db_name} ${db_table} > /tmp/${db_table}_`date +%F-%H-%M-%S`.sql
create table ${db_table}.bak select id,modified,bid,status from ${db_table} limit 100;

还原表

mysql -h${db_host} -u${db_user} -p${db_password} -P${db_port} ${db_name} < /tmp/${db_table}.sql
mysql -h${db_host} -u${db_user} -p${db_password} -P${db_port} ${db_name}; source /tmp/${db_table}.sql

mysql.cnf

# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

#
# The MySQL  Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
pid-file	= /var/run/mysqld/mysqld.pid
socket		= /var/run/mysqld/mysqld.sock
datadir		= /var/lib/mysql
#log-error	= /var/log/mysql/error.log
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

character-set-server=utf8

密码加固建议

加固建议
登录mysql数据库;
查看数据库用户密码信息:`SELECT user, host, authentication_string FROM user;` 部分版本查询命令为:`SELECT user, host, password FROM user;` 
根据查询结果及弱密码告警信息修改具体用户的密码:`SET PASSWORD FOR '用户名'@'主机' = PASSWORD('新密码');`
执行刷新命令:`flush privileges;` 
新口令应符合复杂性要求:

1、长度8位以上
2、包含以下四类字符中的三类字符:
英文大写字母(A 到 Z)
英文小写字母(a 到 z)
10 个基本数字(0 到 9)
非字母字符(例如 !、$、#、%、@、^、&)
3、避免使用已公开的弱口令,如:abcd.1234 、admin@123等
posted @ 2021-05-15 09:28  AlexG  阅读(44)  评论(0编辑  收藏  举报