说明:本文使用在Centos7 系统下使用yum安装
配置yum源
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
安装mysql源
yum localinstall mysql80-community-release-el7-3.noarch.rpm
安装mysql
yum install mysql-community-server
启动mysql服务
systemctl start mysqld //或者 service mysqld start
设置开机启动
systemctl enable mysqld
systemctl daemon-reload
修改登录密码
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
//输入查询出的密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Test@123'; //密码策略请度娘查询修改方式,本文使用默认策略,不做修改
添加远程登录用户
//默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户。
use mysql;
select host, user from user; //查看用户信息
update user set host = '%' where user ='root'; //或者下命令
GRANT ALL ON *.* TO 'root'@'%'; //授权root用户远程访问权限
flush privileges; //立即生效
链接时出现2058异常
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
网友评论