1.下载mysql
在/mydevelop/mysql/目录下执行命令
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar
或者直接在浏览器打开链接,下载后上传到服务器/mydevelop/mysql/
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar
2.解压
tar -xvf mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar
蓝线画出的四个包为安装所需要的包
3.安装前环境清理
首先查看有没有安装mysql或mariadb
rpm -qa | grep mariadb
rpm -qa | grep mysql
如果存在的话 rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64 命令卸载全部包
卸载mysql要完全删除干净(卸载包及删除文件)
4.安装
安装Mysql安装顺序安装
rpm -ivh mysql-community-common-5.7.24-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.24-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.24-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.24-1.el7.x86_64.rpm
安装rpm -ivh mysql-community-server-5.7.24-1.el7.x86_64.rpm可能会报错:
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.24-1.el7.x86_64.....
缺少libaio包 安装 yum install libaio 后再安装 rpm -ivh mysql-community-server-5.7.24-1.el7.x86_64.rpm 则可以
5.启动
启动Mysql服务 : systemctl start mysqld
查看MySQL服务器的状态: systemctl status mysqld
设置开机启动:systemctl enable mysqld
生成随机密码 :grep 'temporary password' /var/log/mysqld.log
初始化默认密码
mysql -uroot -p屏幕上的随机密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'SHSac@2018';
允许root用户在任何地方进行远程登录,并具有所有库任何操作权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'SHSac@2018' WITH GRANT OPTION;
刷新权限
FLUSH PRIVILEGES;
网友评论