进入https://dev.mysql.com/downloads/repo/yum/页面选择合适的系统的源进行下载,我这里使用的centos7所以使用源https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm
下载:
wget https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm
安装:
sudo yum install mysql80-community-release-el7-7.noarch.rpm
yum repolist all | grep mysql
$> sudo yum-config-manager --disable mysql57-community
$> sudo yum-config-manager --enable mysql80-community
或编辑文件 /etc/yum.repos.d/mysql-community.repo file
修改enabled=0
关闭,enabled=1
开启
# Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 8.0
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
查看MySQL对应开启的源 yum repolist enabled | grep mysql
sudo yum module disable mysql
没有就跳过sudo yum install mysql-community-server
---> 软件包 mariadb-server.x86_64.1.5.5.68-1.el7 将被 取代
--> 正在处理依赖关系 mariadb-server,它被软件包 akonadi-mysql-1.9.2-4.el7.x86_64 需要
---> 软件包 mysql-community-client-plugins.x86_64.0.8.0.31-1.el7 将被 安装
---> 软件包 mysql-community-libs.x86_64.0.8.0.31-1.el7 将被 舍弃
--> 正在检查事务
---> 软件包 mariadb-server.x86_64.1.5.5.68-1.el7 将被 取代
--> 正在处理依赖关系 mariadb-server,它被软件包 akonadi-mysql-1.9.2-4.el7.x86_64 需要
---> 软件包 mysql-community-libs-compat.x86_64.0.8.0.31-1.el7 将被 舍弃
--> 解决依赖关系完成
错误:软件包:akonadi-mysql-1.9.2-4.el7.x86_64 (@anaconda)需要:mariadb-server正在删除: 1:mariadb-server-5.5.68-1.el7.x86_64 (@anaconda)mariadb-server = 1:5.5.68-1.el7取代,由: mysql-community-server-8.0.31-1.el7.x86_64 (mysql80-community)未找到您可以尝试添加 --skip-broken 选项来解决该问题您可以尝试执行:rpm -Va --nofiles --nodigest
使用命令移除mariadb-libs yum -y remove mariadb-libs
,重新运行安装命令。
6. 然后就是一路确认安装即可。
systemctl start mysqld
或service mysqld start
systemctl status mysqld
'root'@'localhost
,其默认密码生成路径为/var/log/mysqld.log
sudo grep 'temporary password' /var/log/mysqld.log
或 cat /var/log/mysqld.log
[root@localhost]# cat /var/log/mysqld.log
2022-12-01T15:56:28.931265Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.31) initializing of server in progress as process 61451
2022-12-01T15:56:28.940674Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-12-01T15:56:29.973257Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-12-01T15:56:31.097144Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: g&yP+f_T_1V.
2022-12-01T15:56:33.377470Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31) starting as process 61644
2022-12-01T15:56:33.665946Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-12-01T15:56:35.150925Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-12-01T15:56:35.885498Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-12-01T15:56:35.885596Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-12-01T15:56:35.995928Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.31' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
2022-12-01T15:56:35.996186Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
mysql -uroot -p
输入自己对应的临时密码ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
用户创建、权限相关:https://blog.csdn.net/u013271384/article/details/118438047
官方网址:https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
密码验证相关:https://dev.mysql.com/doc/refman/8.0/en/validate-password.html