Mysql8 示例

mysql 可以根据官方下载包进行安装测试

现在 Centos 7默认是mariadb数据库,再去安装mysql之前要先下载mariadb;

Centos 7 环境检查
rpm -qa | grep mariadb
rpm -e mariadb-libs-5.5.65-1.el7.x86_64 --nodeps
rpm -e mariadb-devel-5.5.65-1.el7.x86_64 --nodeps
yum install perl-JSON.noarch -y

 下列以安装 mysql 8.0 为示例:

默认包
rpm
-ivh mysql-community-common-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-embedded-compat-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-devel-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-test-8.0.20-1.el7.x86_64.rpm

 mysql8 安装之后需要重新修改root密码 或者新增账户

密码可以在初始化启动时,查看日志看到

# grep -a password /var/log/mysqld.log

[Note] [MY-010454] [Server] A temporary password is generated for root@localhost: RLm7?frP/hnE

可以从日志里面检索看到

 修改 mysql 默认密码

mysql> alter USER 'root'@'localhost' IDENTIFIED BY '1qaz@WSX3edc$RFV';
mysql> flush privileges;

查看默认账户

# 查看所有用户是否可以远程连接,依次执行下列命令:
show databases; use mysql;
select host, user, authentication_string, plugin from user;

 新增账户示例

新增账户和权限
create user 'redis'@'%' identified by '1qaz@WSX';
grant all privileges on *.* to 'redis'@'%' with grant option;

 

posted @ 2022-03-14 15:08  01234567  阅读(72)  评论(0编辑  收藏  举报