kkikiako 2019-06-30
groupadd mysql useradd -g mysql mysql passwd mysql
#查询 rpm -qa|grep mariadb
返回 mariadb-libs-5.5.60-1.el7_5.x86_64
#卸载 rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64
返回
error: Failed dependencies: libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-7.el7.x86_64 libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-7.el7.x86_64
#强行卸载 rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
下载mysql rpm
选择
Red Hat Enterprise Linux / Oracle Linux
Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit)
RPM Bundle
取得下载地址
https://cdn.mysql.com//Downlo...
wget "https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar" tar -xvf mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar
安装依赖
yum install -y libaio.x86_64 libaio-devel.x86_64 yum install -y openssl-devel.x86_64 openssl.x86_64 yum install -y perl.x86_64 perl-devel.x86_64 yum install -y perl-JSON.noarch yum install -y autoconf
必要安装,注意顺序,有依赖关系
rpm -ivh mysql-community-common-8.0.13-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.13-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.13-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.13-1.el7.x86_64.rpm
非必要安装,注意顺序,有依赖关系
rpm -ivh mysql-community-libs-compat-8.0.13-1.el7.x86_64.rpm rpm -ivh mysql-community-embedded-compat-8.0.13-1.el7.x86_64.rpm rpm -ivh mysql-community-devel-8.0.13-1.el7.x86_64.rpm rpm -ivh mysql-community-test-8.0.13-1.el7.x86_64.rpm
mysqld --initialize --console
此步骤必须在初始化数据库之后!!!
安装完默认是mysql 用户、用户组的权限,如果没有,则更改
chown -R mysql:mysql /var/lib/mysql/
systemctl start mysqld
若启动失败,查看日志
tail -n 100 /var/log/mysqld.log
启动成功后可以查看初始化密码随机生成的
cat /var/log/mysqld.log | grep password
mysql -u root -p #修改密码 alter user 'root'@'localhost' identified by 'yourpassword'; #远程设置 use mysql; update user set host='%' where user='root'; #授权用户名的权限,赋予任何主机访问数据的权限 grant all privileges ON *.* to 'root'@'%' with grant option; flush privileges;
create user 'flame'@'%' identified by 'password'; create database flame; grant all privileges on flame.* to 'flame'@'%'; flush privileges;
# 开放3306端口 firewall-cmd --zone=public --add-port=3306/tcp --permanent #重载 firewall-cmd --reload #查看状态 firewall-cmd --list-all
安全组说明
新增3306端口的新增【入方向】规则
mysql_secure_installation
会做以下操作
#启动mysql systemctl start mysqld.service #结束 systemctl stop mysqld.service #重启 systemctl restart mysqld.service #开机自启 systemctl enable mysqld.service