mysql@
数据库
mysql 笔记
学习mysql中查了很多资料,有些常用又可能会忘记的内容,为了避免再次麻烦地查资料,记录如下:
8.0版本正确用法:
https://blog.csdn.net/starshards_/article/details/81079242
8.0正确安装配置方法:
https://www.jb51.net/article/145036.htm
django配置mysql8.0报错解决方法:
https://blog.csdn.net/qq_35304570/article/details/79674449
mysql 增加用户,设置权限
1.修改密码
mysql 报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executin
https://blog.csdn.net/memory6364/article/details/82426052
8.0版本修改密码安全等级方法:
https://blog.csdn.net/HaHa_Sir/article/details/80552663
cat /var/log/mysqld.log | grep password // 获取初始密码
mysql> alter user 'root'@'localhost' identified by 'youpassword';修改初始密码
mysql> set password=password("youpassword");
8.0版本:创建用户的操作已经不支持grant的同时创建用户的方式,需先创建用户再进行授权
mysql> grant all on *.* to 'admin'@'%' identified by 'admin123';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'admin123'' at line 1
mysql> create user 'admin'@'%' identified by 'admin123';
Query OK, 0 rows affected (0.06 sec)
mysql> grant all on *.* to 'admin'@'%' ;
Query OK, 0 rows affected (0.04 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
格式:`
mysql> set password for 用户名@localhost = password('新密码');`
例子:`
mysql> set password for root@localhost = password('123');`
方法2:用UPDATE直接编辑user表
mysql> use mysql;
mysql> update user set password=password('123') where user='root' and host='localhost';
mysql> flush privileges;
方法4:在忘记root密码的时候,可以这样
以windows为例:
1. 关闭正在运行的MySQL服务。
2. 打开DOS窗口,转到mysql\bin目录。
3. 输入`mysqld --skip-grant-tables` 回车。--skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证。
4. 再开一个DOS窗口(因为刚才那个DOS窗口已经不能动了),转到mysql\bin目录。
5. 输入mysql回车,如果成功,将出现MySQL提示符 >。
6. 连接权限数据库: `use mysql;` 。
7. 改密码:`update user set password=password("123") where user="root";`(别忘了最后加分号) 。
8. 刷新权限(必须步骤):`flush privileges;` 。
9. 退出 `quit`。
10. 注销系统,再进入,使用用户名root和刚才设置的新密码123登录。
2.添加用户并添加权限
or>grant