mysql 使用记录
修改 mysql 数据库密码
mysqladmin -u username -h host_name password -P <port> "new_password" -p
mysql> set password for 'username'@'host_name'=password('new_password');
mysql> update mysql.user set password=password('new_pasword') where condition;
mysql免密码登录
在用户家目录下添加.my.cnf
文件
[client]
user=root
password=mysql@123
mysql 5.7 安装后启动默认不生成密码
mysql升级到5.7,安装后启动默认会生成密码;可以通过 --initialize-insecure
禁用密码自动生成
修改 /usr/bin/mysqld_pre_systemd文件,修改如下配置
- /usr/sbin/mysqld ${instance:+--defaults-group-suffix=@$instance} --initialize \
+ /usr/sbin/mysqld ${instance:+--defaults-group-suffix=@$instance} --initialize-insecure \
常用命令
# 清空表
truncate table students_bak
max_prepared_stmt_count参数
mysql> set global max_prepared_stmt_count=100000;