系统服务-mysql

2021/8/1 2:06:00

本文主要是介绍系统服务-mysql,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

卸载mariadb

yum list installed | grep mariadb | awk '{print $1}' | xargs yum erase -y

添加mysqlyum源

wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
cp mysql-community.repo mysql-community.repo.bak
sed -i 's#repo.mysql.com/yum#mirrors.tuna.tsinghua.edu.cn/mysql/yum#; s/mysql-\([0-9]\)\.\([0-9]\)/mysql\1\2/; s#/el/\([0-9]\)/#-el\1/#; s#$basearch/##'  mysql-community.repo
  • 默认安装了mysql8版本,要修改默认安装版本的话,可以直接修改mysql的yum源文件,yum配置文件里从5.5版本到8.0都有,只不过默认只开启了mysql8.0。更改别的版本记得将mysql8.0的源改为enable=0

执行安装

yum install mysql-community-server
systemctl start mysqld
systemctl enable mysqld

用户密码

#root用户设置密码
set global validate_password.policy =0;
set global validate_password.length=1;
alter user 'root'@'localhost' identified by  '123.com';

#添加普通用户
create database cmdb;
create user 'cmdb'@'192.168.0.%' identified with mysql_native_password by '123.com';
grant all privileges on cmdb.* to 'cmdb'@'192.168.0.%';

#重置用户密码
alter user 'cmdb'@'192.168.0.%' identified by 'abc.com';


这篇关于系统服务-mysql的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程