Linux CentOS 7 安装mysql的步骤

#wget命令用来从指定的URL下载文件
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server

重启mysql服务
service mysqld restart  ||  systemctl restart mysqld.service

mysql -uroot 回车

默认安装完,root是没有密码的,需要手动添加密码
#set password for 'root'@'localhost'=password('密码');
set password for 'root'@'localhost'=password('root');

#给root用户赋予远程登录权限
grant all privileges on *.*  to root@'%' identified by 'root' with grant option; 

#刷新mysql权限
flush privileges;

#开放3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent

#重启防火墙
systemctl restart firewalld

你可能感兴趣的:(linux,centos,mysql)