标签:local alter user remove you where systemctl cli 刷新
清理原有的mysql
rpm -qa |
grep
mysql
#可能的显示情况如下
#mysql-community-libs-8.0.12-1.el7.x86_64
#mysql80-community-release-el7-1.noarch
#mysql-community-client-8.0.12-1.el7.x86_64
#mysql-community-common-8.0.12-1.el7.x86_64
#mysql-community-server-8.0.12-1.el7.x86_64
#通过下面的命令进行删除
yum remove mysql-xxx-xxx- --nodeps
#查找mysql的相关文件
find
/ -name mysql
#根据自身的需求删除mysql的配置文件信息
rm
-rf
/var/lib/mysql
rpm -qa |
grep
mariadb
#查找mariadb
#可能出现的结果mariadb-libs-5.5.56-2.el7.x86_64
#将查找出来的结果进行强制删除
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
cd
/usr/src
wget https:
//dev
.mysql.com
/get/mysql80-community-release-el7-1
.noarch.rpm
#安装yum源
yum localinstall mysql80-community-release-el7-1.noarch.rpm
#更新yum源
yum clean all
yum makecache
#开始安装MySQL
yum
install
mysql-community-server
#启动MySQL
systemctl start mysqld
#启动成功后可以查看初始化密码随机生成的
cat
/var/log/mysqld
.log |
grep
password
#登录MySQL修改mysql用户密码
mysql -u root -p
mysql> ALTER USER
‘root‘
@
‘localhost‘
IDENTIFIED BY
‘yourpassword‘
;
#远程设置
mysql> use mysql;
mysql> update user
set
host=
‘%‘
where user=
‘root‘
;
#授权用户名的权限,赋予任何主机访问数据的权限
mysql> GRANT ALL PRIVILEGES ON *.* TO
‘root‘
@
‘%‘
WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
#允许myuser用户使用mypassword密码从任何主机连接到mysql服务器
GRANT
ALL
PRIVILEGES
ON
*.*
TO
‘myuser‘
@
‘%‘
IDENTIFIED
BY
‘mypassword‘
WITH
GRANT
OPTION
;
#允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码
GRANT
ALL
PRIVILEGES
ON
*.*
TO
‘myuser‘
@
‘192.168.1.3‘
IDENTIFIED
BY
‘mypassword‘
WITH
GRANT
OPTION
;
#启动mysql
systemctl start mysqld.service
#结束
systemctl stop mysqld.service
#重启
systemctl restart mysqld.service
#开机自启
systemctl
enable
mysqld.service
#修改加密规则 (这行我没有写,不过貌似也可以)密码需要设置包含大小写字母符号和数字的格式,否则设置不会超成功
ALTER USER
‘root‘
@
‘%‘
IDENTIFIED BY
‘password‘
PASSWORD EXPIRE NEVER;
#更新一下用户的密码
ALTER USER
‘root‘
@
‘%‘
IDENTIFIED WITH mysql_native_password BY
‘password‘
;
#刷新权限
FLUSH PRIVILEGES;
标签:local alter user remove you where systemctl cli 刷新
原文地址:https://www.cnblogs.com/xiaowangbangzhu/p/10316338.html