centos7安装mysql
mysql安装过程
[root@weikeu ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
[root@weikeu ~]# yum localinstall mysql57-community-release-el7-11.noarch.rpm
[root@weikeu ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community 108
mysql-tools-community/x86_64 MySQL Tools Community 90
mysql57-community/x86_64 MySQL 5.7 Community Server 347
[root@weikeu ~]# yum install mysql-community-server –y
[root@weikeu ~]# systemctl start mysqld.service
[root@weikeu ~]# ps -ef | grep mysql
[root@weikeu ~]# systemctl enable mysqld.service
[root@weikeu ~]# grep 'temporary password' /var/log/mysqld.log
2019-06-04T11:59:01.477099Z 1 [Note] A temporary password is generated for root@localhost: P0Deait,dWr6
[root@weikeu ~]# mysql -p'P0Deait,dWr6'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> SET PASSWORD = PASSWORD("AWas@4@5##ji5");
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'AWas@4@5##ji5' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Mysql8安装及问题总结
Mysql8安装成功后,首次进入mysql
cat mysqld.log | grep password
找到临时密码
mysql -uroot -p 输入临时密码登录成功
输入mysql语句报错 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
解决方法 alter user 'root'@'localhost' identified by '你的密码包含大小写及特殊符号8位以上';
flush privileges;
\q退出
使用新密码,重新登录mysql -uroot -p
允许root用户远程访问,则要修改权限
1.登录数据库
mysql -uroot -p 回车
输入密码… 回车
2.登录成功后,切换数据库
use mysql;
3.查看当前用户
select user,host from user;
4.允许root用户远程访问
update user set host='%' where user='root';
GRANT ALL ON . TO 'root'@'%';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的数据库密码';
Navicat远程连接数据库成功
建站时无法连接数据库,报错The server requested authentication method unknown to the client
这是因为mysql8 验证方式与之前的版本不同
在my.cnf中加一句:
default_authentication_plugin=mysql_native_password
变成原来的验证方式即可
作者: 走过测试
转载请注明原文链接:https://www.cnblogs.com/weikeu/p/15904471.html
关于作者:专注渗透测试、安全攻防领域,微信号 734791767 请多多赐教!
个人博客 http://weikeu.com 评论和私信会在第一时间回复。或者直接私信我
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出,如有问题,请留言.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了