0.修改局域网访问权限
CREATE USER 'wordpress_user'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'wordpress_user'@'%';
FLUSH PRIVILEGES;
1.修改密码方式
1)方式1
mysqladmin -u root -p'123456' password'123456'
2)方式2
update user set password = password('123456') where user='root' and host = '%'
flush privileges;
3)方式3:当前用户
mysql> set password=password('123456')
2.找回丢失的mysql密码
1)先停止服务
2)使用--skip-grant-tables启动mysql,忽略授权登录验证
mysqld_safe --skip-grant-tables --user=mysql & mysql -u root -p
3.显示连接删除数据库
1) show databases;
2) show databases like ‘%oldboy%’;
3) select database() 查看当前连接数据库
4) use database
5) drop database test 删除数据库
7) select version(); 查看当前版本
8) select user(); 查看当前用户
9) select new(); 查看当前时间
10)show tables; 查看当前数据库表
11)show tables from test 查看指定数据库中的表
12)show tables in test
13)drop user '用户'@‘主机域’ 删除系统多余账号
drop user 'user1'@'localhost';
flush privileges;
14)drop user 无法删除时
delete from test.user where user='root' and host='user1';
flush privileges;
4.创建mysql用户及授权的多种方式
1)创建用户 identified : 密码
create user 'user002'@'localhost' identified by 'SN'
2) 授权用户:
grant all privileges on db1.* to 'user002'@'localhost' identified by 'SN'
| grant | all privileges | on db1.* | to 'user002'@'localhost' | identified by 'SN' |
| 授权 | 操作权限 | 库.表 | 用户和主机 | 用户密码 |
3)select host,user from mysql.user; 查看用户
4)show grants for 'user002'@'localhost'; 查看用户权限
5.配置
[mysqld]
port=3306
datadir=E:/YL/WMS/db
max_connections=500
6.too many connections
查看实际进程数
SHOW FULL PROCESSLIST;
已经占用最大连接数
show global status like 'Max_used_connections';
显示最大连接数
show variables like 'max_connections'
显示等待时间,如果是默认28800秒
SHOW VARIABLES LIKE 'wait_timeout';
暂时改成60秒,等一段时间,在看看PROCESSLIST
SET GLOBAL wait_timeout = 60;
SELECT @@global.wait_timeout, @@session.wait_timeout, @@global.interactive_timeout, @@session.interactive_timeout;
6.查看mysql5.6配置文件位置
1.安装路径,例如:C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe
2.配置目录,例如:"C:\ProgramData\MySQL\MySQL Server 5.7\my.ini"
更快速的方法:
打开Windows --服务(本地)--找到MySQL 服务---右键--属性---可执行文件路径---找到 --defaults-file= 后面就是
7.thread_cache_size
mysql> show global status like 'Thread%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_cached | 2 |
| Threads_connected | 1 |
| Threads_created | 3 |
| Threads_running | 2 |
+-------------------+-------+
当 Threads_cached 越来越少 但 Threads_connected 始终不降,且 Threads_created 持续升高,可适当增加 thread_cache_size 的大小,4G增加50-100
8.max_connections
1)如果状态变量 connection_errors_max_connections 不为零,并且一直增长,则说明不断有连接请求因数据库连接数已达到允许最大值而失败,这是可以考虑增大max_connections 的值
2)夺该值的大小,max_used_connections / max_connections * 100% (理想值≈ 85%) 如果max_used_connections跟max_connections相同 那么就是max_connections设置过低或者超过服务器负载上限了,低于10%则设置过大,
本文详细介绍了如何在MySQL中修改密码,包括三种不同的方法。此外,还涵盖了找回丢失密码的步骤,以及显示和删除数据库的操作。重点讲解了用户权限的管理,包括创建用户、授权以及权限的查看。同时,提到了本地和远程主机的授权方法,以及用户和权限相关表的查询。最后,讨论了多种用户授权方式和权限级别。
3718

被折叠的 条评论
为什么被折叠?



