一、安装mysql
1.yum源安装
配置yum,下载阿里的repo
wget http://mirrors.aliyun.com/repo/Centos-8.repo
查看mysql相关可用包
yum list mysql*
安装mysql
yum -y install mysql-devel.x86_64
yum -y install mysql-server.x86_64
查看已安装的包
yum list installed mysql*
2.安装包安装
在mysql官网下载对应版本安装包https://downloads.mysql.com/archives/community/
通过ftp传输mysql安装包
创建目录并解压
mkdir mysql
tar -xvf mysqlxxx.tar
安装mysql
rpm -ivh mysql-community-common-xxx.rpm
rpm -ivh mysql-community-client-plugins-xxx.rpm
rpm -ivh mysql-community-libs-xxx.rpm
rpm -ivh mysql-community-libs-compat-xxx.rpm
yum install openssl-devel
rpm -ivh mysql-community-devel-xxx.rpm
rpm -ivh mysql-community-client-xxx.rpm
rpm -ivh mysql-community-server-xxx.rpm
查询自动生成root用户的密码
grep 'temporary password' /var/log/mysqld.log
二、配置mysql
配置mysql-conf
vim /etc/my.cnf.d/mysql-server.cnf
配置字符格式及引擎
[mysqld]
character_set_server=utf8
default-storage-engine=INNODB
三、相关服务操作
启动mysql服务
service mysqld start
systemctl start mysqld
systemctl restart mysqld
systemctl stop mysqld
四、mysql相关操作
登录mysql
mysql -u root -p
更改密码
alter user 'root'@'localhost' identified by '123456';
指向上述语句可能会报错,可以降低密码校验规则
set global validate_password.policy = 0;
set global validate_password.length = 4;
五、Navicat连接阿里云上部署的mysql
创建用户用于远程访问,并给root用户赋权
create user 'root'@'%' identified with mysql_native_password by '123456';
grant all on *.* to 'root'@'%';
阿里云上设置mysql3306端口开放
为root账号赋权
update user set Host='%' where User='root';