下载mysql仓库
#mysql的安装源
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
yum是软件管理工具,管理rpm,yum可以自动安装需要的依赖软件
安装mysql安装源
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
安装mysql8
yum install mysql-server
寻找初始root密码:( A temporary password is generated for root@localhost: xxxxxxx)
tail -f /var/log/mysqld.log
登录mysql,修改密码
mysql -uroot -p
设置密码,创建用户
ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxxxxxx';
create user '用户名称'@'%' identified with mysql_native_password by '密码';
mysql_native_password: 表示使用旧版本的加密方式,支持旧的navicat等客户端软件
启动和管理mysql:
systemctl start mysqld.service #启动
systemctl stop mysqld.service #关闭
systemctl restart mysqld.service #重启
systemctl status mysqld.service #查看状态
systemctl enable mysqld.service #开机自启动
systemctl disable mysqld.service #开机不自启动
把3306加入防火墙的例外,允许外部访问
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload 重新加载
firewall-cmd --zone=public --query-port=3306/tcp #查看开放状态
systemctl stop firewalld.service # 关闭防火墙,重启会重新开启
systemctl disable firewalld.service #禁止开机启动防火墙
创建数据库deepmovie并授权给wade账号
create database deepmovie charset utf8; #创建数据库
drop database deepmovie; #删除数据库
grant all privileges on *.* to 'wade'@'%'; #授权所有库表+所有权限给wade在任何地方访问
flush privileges; #刷新授权
注:
rpm -qa | grep mysql #搜索查询
rpm -e mysql80-community-release-el7-3.noarch #卸载