文章目录
Linux安装、卸载MySQL
一、卸载系统自带的mariadb-lib
二、上传安装包并解压
三、按顺序安装
错误1:
错误2:
错误3:
错误4:
四、初始化数据库
五、目录授权,否则启动失败
六、启动msyql服务
七、查看msyql服务的状态
八、在/var/log/mysqld.log下查看临时密码
九、用临时密码登录到数据库
十、执行下列mysql命令 修改密码
十一、依次执行下列mysql命令 授权远程连接
Linux安装、卸载MySQL
一、卸载系统自带的mariadb-lib
查看mariadb版本
rpm -qa | grep mariadb
卸载mariadb
rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
删除mariadb默认配置文件
rm -rf /etc/my.cnf
重启机器
reboot
二、上传安装包并解压
将mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar
安装包上传到/export/software目录
解压mysql安装包到/export/server目录
mkdir /export/servertar -xvf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar -C /export/server
三、按顺序安装
yum install numactl openssl-devel.x86_64 openssl.x86_64 autoconf perl.x86_64 perl-devel.x86_64 perl-JSON.noarch -y
必须安装(注意顺序)
rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm
如何报以下错误:
错误1:
error:
Failed dependencies:
libnuma.so.1()(64bit) is needed by mysql-community-server-8.0.18-1.el7.x86_64 libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-8.0.18-1.el7.x86_64 libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-8.0.18-1.el7.x86_64
解决办法:
yum install numactl
错误2:
出现问题:
error:
Failed dependencies:
pkgconfig(openssl) is needed by mysql-community-devel-8.0.18-1.el7.x86_64
解决办法:
yum install openssl-devel.x86_64 openssl.x86_64 -y
错误3:
error:
Failed dependencies:
perl(Data::Dumper) is needed by mysql-community-test-8.0.18-1.el7.x86_64
解决办法:
yum -y install autoconf
错误4:
error:
Failed dependencies:
perl(JSON) is needed by mysql-community-test-8.0.18-1.el7.x86_64
解决办法:
yum install perl.x86\_64 perl-devel.x86\_64 -yyum install perl-JSON.noarch -y
四、初始化数据库
mysqld --initialize --console
五、目录授权,否则启动失败
chown -R mysql:mysql /var/lib/mysql/
六、启动msyql服务
systemctl start mysqld
将mysql服务设置为开机启动
systemctl enable mysqldsystemctl daemon-reload
七、查看msyql服务的状态
service mysqld status
八、在/var/log/mysqld.log下查看临时密码
cat /var/log/mysqld.log
九、用临时密码登录到数据库
mysql -u root -p
输入临时密码(输入时不会显示出来,输入完直接回车)
十、执行下列mysql命令 修改密码
alter USER 'root'@'localhost' IDENTIFIED BY '新密码';
十一、依次执行下列mysql命令 授权远程连接
查看所有用户是否可以远程连接,依次执行下列命令:
show databases;
use mysql;
select host, user, authentication_string, plugin from user;
host为localhsot,说明用户只能本地连接mysql服务
创建一个root@%
账号,使root用户可以远程登录
开启mysql远程访问权限
use mysql;
create user 'root'@'%';
alter USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root用户的密码';
flush privileges;
-
博客主页:https://lansonli.blog.csdn.net
-
📢欢迎点赞 👍 收藏 ⭐留言 📝 如有错误敬请指正!
-
📢本文由 Lansonli 原创,首发于 CSDN博客🙉
-
📢停下休息的时候不要忘了别人还在奔跑,希望大家抓紧时间学习,全力奔赴更美好的生活✨