关于centos:yum安装MySQL8

48次阅读

共计 1471 个字符,预计需要花费 4 分钟才能阅读完成。

yum 仓库

yum localinstall https://repo.mysql.com//mysql80-community-release-el8-2.noarch.rpm

或者

wget -i -c https://dev.mysql.com/get/mysql80-community-release-el8-2.noarch.rpm
yum -y install mysql80-community-release-el8-2.noarch.rpm

yum 装置 MySQL

yum -y install mysql-community-server

如果提醒以下谬误

Last metadata expiration check: 0:02:05 ago on Thu 18 Nov 2021 08:19:27 PM CST.
All matches were filtered out by modular filtering for argument: mysql-community-server
Error: Unable to find a match: mysql-community-server

需执行

yum module disable mysql

而后从新 install

启动 MySQL 服务:systemctl start mysqld.service
查看 MySQL 服务:systemctl status mysqld.service

此时如果要进入 MySQL 得找出 root 用户的明码,输出命令

grep "password" /var/log/mysqld.log
w&Qsi4IDu9e1

失去明码后,登录 mysql,批改明码

# 登录 MySQL
mysql -uroot -p
# 批改 root 明码
ALTER USER 'root'@'localhost' IDENTIFIED BY '5LNKrDtHsR7$';

创立用户

创立用户:CREATE USER 'admin'@'%' IDENTIFIED BY '5LNKrDtHsR7$';
容许近程连贯:GRANT ALL ON *.* TO 'testdb'@'%';
自己测试过,应用 update user set host = '%' where user = 'root'; 也能够批改

用户调配权限

– 授予用户通过外网 IP 对于该数据库“testdb”的全副权限

grant all privileges on testdb.* to 'admin'@'%' identified by '5LNKrDtHsR7$';  

MySQL8 提醒

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

须要应用上面这种语法

grant all privileges on spy_fb.* to 'facebook'@'%' ;
grant all privileges on spy_logs.* to 'facebook'@'%' ;
grant all privileges on spy_task.* to 'facebook'@'%' ;

# 刷新权限
flush privileges; 

如果应用客户端连贯提醒了 plugin caching_sha2_password 谬误,这是因为 MySQL8.0 的明码策略默认为 caching_sha2_password
应用命令批改策略
ALTER USER 'facebook'@'%' IDENTIFIED WITH mysql_native_password BY 'J5LNKrJ7DtHknsR7$';

正文完
 0