MySQL 安装并修改密码策略

环境
  • centos 6.5
  • mysql 5.7
安装MySQL
//# 添加用户/组
$ groupadd mysql
$ useradd -M -s /sbin/nologin mysql

//# 安装依赖和mysql包
$ yum install numactl
//# 删除系统默认包,会冲突
$ rpm -e --nodeps mysql-libs

//# 按顺序安装
$ yum install -y https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el6/mysql-community-common-5.7.28-1.el6.x86_64.rpm
$ yum install -y https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el6/mysql-community-libs-5.7.28-1.el6.x86_64.rpm
$ yum install -y https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el6/mysql-community-libs-compat-5.7.28-1.el6.x86_64.rpm
$ yum install -y https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el6/mysql-community-devel-5.7.28-1.el6.x86_64.rpm
$ yum install -y https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el6/mysql-community-client-5.7.28-1.el6.x86_64.rpm
$ yum install -y https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el6/mysql-community-server-5.7.28-1.el6.x86_64.rpm

//# 配置my.cnf
$ cat /etc/my.cnf
[client]
port=63751
[mysql]
socket=/cache1/mysql/mysql.sock
default-character-set = utf8
no_auto_rehash
[mysqld]
port=63751
datadir=/cache1/mysql/data
socket=/cache1/mysql/mysql.sock
log-error=/cache1/mysql/mysql_error.err
pid-file=/cache1/mysql/mysqld.pid
character-set-server = utf8
collation-server = utf8_general_ci
symbolic-links=0
explicit_defaults_for_timestamp=true
skip-name-resolve
log-bin = /cache1/mysql/binlog/mysql-bin 
expire_logs_days=5
binlog_format=ROW
sync_binlog=0
server_id=240232
read_only=0
event_scheduler=0
innodb_buffer_pool_size=10G
innodb_io_capacity=200
innodb_flush_neighbors=1
transaction_isolation=READ-COMMITTED
key_buffer_size=256M
max_allowed_packet=16M
sort_buffer_size=2M
read_buffer_size=2M
read_rnd_buffer_size=2M
join_buffer_size=2M
explicit_defaults_for_timestamp=1
max_connections=3000
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
tmp_table_size=128M
max_heap_table_size=128M
group_concat_max_len=64K
default-storage-engine=INNODB
innodb_large_prefix=1
innodb_file_format=barracuda
innodb_strict_mode=1
innodb_stats_on_metadata=0
innodb_file_per_table=1
table_open_cache=2048
thread_cache_size=1024
skip_external_locking
skip_name_resolve
innodb_log_file_size=256M
innodb_flush_log_at_trx_commit=2
character_set_server=utf8
log_bin_trust_function_creators=1
open_files_limit=60000
lower_case_table_names=1
master_info_repository=TABLE
relay_log_info_repository=TABLE
[mysqld_multi]
mysqld=/usr/bin/mysqld_safe
mysqladmin=/usr/bin/mysqladmin
[mysqldump]
quick
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

//# 删除默认目录
$ rm -rf {/root/.mysql_secret,/var/lib/mysql,/root/.mysql_history,/etc/my.cnf.rpmnew,/var/log/mysqld.log}
//# 创建mysql目录
$ mkdir -p /cache1/mysql/binlog
$ mkdir -p /cache1/mysql/data
$ chown -R mysql:mysql /cache1/mysql/

//# 启动服务
$ service mysqld start
$ chkconfig mysqld on
修改默认密码和密码策略
//# 默认密码在错误日志里
$ sed '/A temporary password/!d;s/.*: //' /cache1/mysql/mysql_error.err
$ mysql -uroot -p
mysql> SET PASSWORD = PASSWORD("ROOT_PASS");
mysql> set global validate_password_policy=0;
//# 最少为4
mysql> set global validate_password_length=4;
mysql> set global validate_password_mixed_case_count=0;
mysql> set global validate_password_number_count=0;
mysql> set global validate_password_special_char_count=0;
mysql> show variables like "validate_password%";


//# 在my.cnf配置中关闭密码策略
$ vi /etc/my.cnf
[mysqld]
...
validate_password=0
...

//# 重启
$ service mysqld restart
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值