前言
首先,我们要知道MySQL的国内镜像网站地址
然后就可以进行寻找及下载
访问国内mysql镜像站
-
中国科学技术大学开源软件镜像
-
http://mirrors.ustc.edu.cn/
或者可以直接在上面搜索:
点击这里:
3.下载软件包(这里以mysql8.0为例)-
官方地址下载或百度网盘下载
Index of /mysql-repo/yum/mysql-5.7-community/el/7/x86_64/
-
mysql80
-
https://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-8.0-community/el/7/x86_64/
Index of /mysql-repo/yum/mysql-8.0-community/el/7/x86_64/
需要的依赖包有以下6个
mysql-community-client-8.0.31-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
mysql-community-common-8.0.31-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
mysql-community-libs-8.0.31-1.el7.x86_64.rpm
mysql-community-server-8.0.31-1.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-8.0-community/el/7/x86_64/mysql-community-server-8.0.31-1.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-8.0-community/el/7/x86_64/mysql-community-libs-8.0.31-1.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-8.0-community/el/7/x86_64/mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-8.0-community/el/7/x86_64/mysql-community-common-8.0.31-1.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-8.0.31-1.el7.x86_64.rpm
- 查看
ls ./
- 安装相关软件
如果装的是mysql5.7>需要安装三个相关软件
8.0不需要
yum install -y net-tools.x86_64 libaio.x86_64 perl.x86_64
-
安装Mysql服务器
-
安装主包即可
yum install -y mysql-community-server
- 报错信息
- 解决方法:卸载冲突的软件包,再安装
yum remove -y mariadb-libs-5.5.60-1.el7_5.x86_64
yum remove -y mariadb-libs
yum install -y mysql-community*
如果提示如下报错:
表示安装server,需要其他的依赖
解决方案:
yum install -y mysql-community*
-
安装完毕的提示:
-
启动Mysql服务器
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl enable mysqld
[root@localhost ~]# systemctl status mysqld
[root@localhost ~]# ps -aux |grep mysql
mysql 31791 7.3 20.1 1798984 374516 ? Ssl 02:14 0:01 /usr/sbin/mysqld
- 查询Mysql服务器默认密码
grep 'password' /var/log/mysqld.log
注意:
没有查到密码的原因,是因为没有启动成功。
冒号和空格的后面,全都是密码
登录:
- 可以正常登录,但是无法操作数据库服务器,需要我们修改密码才能操作
mysql -uroot -p'-u4mT?ry#jjn'
[root@web2 ~]# mysql -uroot -p'-u4mT?ry#jjn'
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 8
Server version: 8.0.31
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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> exit
Bye
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
- 修改Mysql服务器密码
修改密码语法:
ALTER USER '数据库用户名'@'localhost' IDENTIFIED BY '新的密码';
[root@web2 ~]# mysql -uroot -p'-u4mT?ry#jjn'
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
#上述提示错误,表示输入的密码太简单
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Nem_Passwd@123';
Query OK, 0 rows affected (0.00 sec)
修改密码为:Nem_Passwd@123
- 登录Mysql系统
[root@localhost ~]# mysql -uroot -p'Nem_Passwd@123'
mysql> show databases;
- 查到默认数据库
实验完成