下载
https://dev.mysql.com/downloads/repo/yum/
上传服务器
$ rz -E
rz waiting to receive.
$ ll
总用量 12
-rw-r--r-- 1 root root 11288 5月 1 14:17 mysql80-community-release-el7-6.noarch.rpm
安装yum源
$ rpm -ivh mysql80-community-release-el7-6.noarch.rpm
警告:mysql80-community-release-el7-6.noarch.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql80-community-release-el7-6 ################################# [100%]
$ ll /etc/yum.repos.d/mysql-community*
-rw-r--r-- 1 root root 1147 4月 8 18:00 /etc/yum.repos.d/mysql-community-debuginfo.repo
-rw-r--r-- 1 root root 2062 4月 8 18:00 /etc/yum.repos.d/mysql-community.repo
-rw-r--r-- 1 root root 2132 4月 8 18:00 /etc/yum.repos.d/mysql-community-source.repo
修改yum源
要安装5.7版本的还需要启用5.7的yum源
$ vim /etc/yum.repos.d/mysql-community.repo
# 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/7/$basearch
#打开5.7的
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch
#关闭8.0的
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
#或者直接用sed修改
$ sed -ri -e '2,7s/^(enabled=).*$/\11/' -e '10,16s/^(enabled=).*$/\10/' -e '2,7s/^(gpgcheck=).*$/\10/' /etc/yum.repos.d/mysql-community.repo
清缓存,重建元数据
$ yum makecache fast
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
epel/x86_64/metalink | 8.4 kB 00:00:00
* base: mirrors.aliyun.com
* epel: hkg.mirror.rackspace.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
* webtatic: us-east.repo.webtatic.com
base | 3.6 kB 00:00:00
development | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
hxgepel | 4.7 kB 00:00:00
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql57-community | 2.6 kB 00:00:00
updates | 2.9 kB 00:00:00
webtatic | 3.6 kB 00:00:00
(1/39): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/39): base/7/x86_64/filelists_db | 7.2 MB 00:00:00
(3/39): base/7/x86_64/primary_db | 6.1 MB 00:00:01
(4/39): base/7/x86_64/other_db | 2.6 MB 00:00:01
(5/39): development/7/x86_64/group_gz | 153 kB 00:00:01
(6/39): development/7/x86_64/primary_db | 6.1 MB 00:00:43
(7/39): epel/x86_64/group_gz | 96 kB 00:00:00
(8/39): epel/x86_64/filelists_db | 12 MB 00:00:01
(9/39): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(10/39): epel/x86_64/prestodelta | 838 B 00:00:00
(11/39): epel/x86_64/primary_db | 7.0 MB 00:00:00
(12/39): epel/x86_64/other_db | 3.4 MB 00:00:00
(13/39): extras/7/x86_64/primary_db | 246 kB 00:00:00
(14/39): extras/7/x86_64/other_db | 147 kB 00:00:00
(15/39): extras/7/x86_64/filelists_db | 277 kB 00:00:00
(16/39): hxgepel/7/x86_64/group_gz | 96 kB 00:00:00
(17/39): hxgepel/7/x86_64/updateinfo | 1.0 MB 00:00:00
(18/39): hxgepel/7/x86_64/prestodelta | 838 B 00:00:00
(19/39): development/7/x86_64/filelists_db | 7.2 MB 00:00:50
(20/39): hxgepel/7/x86_64/primary_db | 7.0 MB 00:00:02
(21/39): hxgepel/7/x86_64/filelists_db | 12 MB 00:00:03
(22/39): hxgepel/7/x86_64/other_db | 3.4 MB 00:00:01
(23/39): mysql-connectors-community/x86_64/primary_db | 87 kB 00:00:01
(24/39): mysql-connectors-community/x86_64/other_db | 23 kB 00:00:00
(25/39): mysql-tools-community/x86_64/primary_db | 86 kB 00:00:01
(26/39): mysql-tools-community/x86_64/other_db | 16 kB 00:00:00
(27/39): mysql-tools-community/x86_64/filelists_db | 325 kB 00:00:02
(28/39): mysql-connectors-community/x86_64/filelists_db | 35 kB 00:00:04
(29/39): mysql57-community/x86_64/primary_db | 306 kB 00:00:00
(30/39): updates/7/x86_64/filelists_db | 8.2 MB 00:00:00
(31/39): updates/7/x86_64/other_db | 1.0 MB 00:00:00
(32/39): mysql57-community/x86_64/other_db | 82 kB 00:00:00
(33/39): updates/7/x86_64/primary_db | 15 MB 00:00:01
(34/39): webtatic/x86_64/group_gz | 448 B 00:00:01
(35/39): mysql57-community/x86_64/filelists_db | 1.8 MB 00:00:04
(36/39): webtatic/x86_64/primary_db | 271 kB 00:00:02
(37/39): development/7/x86_64/other_db | 2.6 MB 00:00:16
(38/39): webtatic/x86_64/other_db | 72 kB 00:00:04
(39/39): webtatic/x86_64/filelists_db | 97 kB 00:00:09
元数据缓存已建立
安装数据库
$ yum install mysql-server mysql mysql-common mysql-libs -y
检查配置文件
$ ll /etc/my.cnf
-rw-r--r-- 1 root root 960 3月 22 02:00 /etc/my.cnf
$ date
2022年 05月 01日 星期日 14:36:41 CST
#是最新的
启动服务
$ systemctl start mysqld
查看初始化密码
$ cat /var/log/mysqld.log | grep password
2022-05-01T06:38:29.550471Z 1 [Note] A temporary password is generated for root@localhost: sbBwl+wiG8ya
密码为sbBwl+wiG8ya
登录测试
$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
无法操作
修改密码
mysql> alter user 'root'@'localhost' identified by '111111';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> set password=password('111111');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' identified by 'Mysql@123';
Query OK, 0 rows affected (0.00 sec)
yum安装的mysql 密码不能太简单
可以通过修改数据库密码规则来解决
可以参考另一篇随笔 https://www.cnblogs.com/guangdelw/p/16991028.html
标签:39,x86,db,00,yum,mysql,64,在线 From: https://www.cnblogs.com/guangdelw/p/16991041.html