ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

centos7安装mysql

2022-02-17 14:34:42  阅读:117  来源: 互联网

标签:安装 MySQL weikeu community centos7 mysql password root


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)

image-20211112160628888

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

image-20211112160709964

允许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 '你的数据库密码';

image-20211112160738614

image-20211112160805180

image-20211112160826691

Navicat远程连接数据库成功

建站时无法连接数据库,报错The server requested authentication method unknown to the client

这是因为mysql8 验证方式与之前的版本不同

在my.cnf中加一句:
default_authentication_plugin=mysql_native_password
变成原来的验证方式即可

标签:安装,MySQL,weikeu,community,centos7,mysql,password,root
来源: https://www.cnblogs.com/weikeu/p/15904471.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有