yum仓库
yum localinstall https://repo.mysql.com//mysql80-community-release-el8-2.noarch.rpm
或者mysql
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
若是提示如下错误sql
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
而后从新installide
启动MySQL服务:systemctl start mysqld.service
查看MySQL服务:systemctl status mysqld.service
测试
此时若是要进入MySQL得找出root用户的密码,输入命令code
grep "password" /var/log/mysqld.log
w&Qsi4IDu9e1
获得密码后,登陆mysql,修改密码server
# 登陆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';
也能够修改get
用户分配权限
--授予用户经过外网IP对于该数据库“testdb”的所有权限it
grant all privileges on testdb.* to 'admin'@'%' identified by '5LNKrDtHsR7$';
MySQL8提示io
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$';