Linux下安装mysql8.0

下载页面:https://dev.mysql.com/downloads/repo/yum/

此处采用yum安装,说明页面 MySQL :: A Quick Guide to Using the MySQL Yum Repository

Linux下安装mysql8.0_第1张图片

1、选择Yum Repository 页面 https://dev.mysql.com/downloads/repo/yum/

下载rpm

Linux下安装mysql8.0_第2张图片

2、在 /mydata/mysql 目录下下载rpm文件

wget https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm

 3、添加Yum repository

 sudo rpm -Uvh mysql80-community-release-el7-7.noarch.rpm

 4、检查MySQL在Yum repository默认版本

[root@shuidi-101 mysql]# yum repolist enabled | grep mysql

5、安装

sudo yum install mysql-community-server

6、启动mysql

systemctl start mysqld

 7、检查mysql是否启动成功

systemctl status mysqld

8、获取默认密码

[root@shuidi-101 mysql]# sudo grep 'temporary password' /var/log/mysqld.log
2022-11-10T06:33:04.738089Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: o!-Vavop<1nX

默认密码:o!-Vavop<1nX

 9、修改默认密码

[root@shuidi-101 mysql]# mysql -uroot -p
Enter password: 
输入密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxxx';

10、设置外网可访问

use mysql;

查询host输入
select user,host from user;

11、创建host(如果有"%"这个host值,则跳过这一步)

  如果没有"%"这个host值,就执行下面这两句:

mysql> update user set host='%' where user='root';
mysql> flush privileges;

授权用户

(1)任意主机以用户root和密码pwd连接到mysql服务器

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Grant all privileges on *.* to 'root'@'%';
FLUSH PRIVILEGES;
 exit;

Linux下安装mysql8.0_第3张图片

你可能感兴趣的:(运维,linux,服务器,运维)