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.rpmyum -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-serverError: 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.logw&Qsi4IDu9e1
失去明码后,登录mysql,批改明码
# 登录MySQLmysql -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$';