检查
-
如果存在则卸载
rpm -qa|grep mariadb
-
请先执行卸载命令
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
-
必须有如下两个包
rpm -qa|grep libaio
rpm -qa|grep net-tools -
若没有,用yum进行安装
yum install libaio
yum install net-tools
安装MySQL
-
下载以下四个文件,上传到Linux进行安装
mysql-community-common
mysql-community-libs
mysql-community-client
mysql-community-server -
依次安装
rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm -
查看版本确认安装
mysqladmin --version
设置MySQL
-
初始化服务
mysqld --initialize --user=mysql
-
查看密码
cat /var/log/mysqld.log
root@localhost: 后面就是初始化的密码 -
启动服务
启动:systemctl start mysqld.service
停止:systemctl stop mysqld.service -
登录并修改密码
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
-
修改字符集
在最后加上中文字符集配置
vim /etc/my.cnf
character_set_server=utf8 -
重启
systemctl restart mysqld.service
授权远程连接
-
再次登录mysql 授予远程连接
grant all privileges on *.* to root@'%' identified by 'root';
-
刷新权限
flush privileges;
-
关闭防火墙
一次关闭
systemctl stop firewalld.service
永久关闭
systemctl disable firewalld.service -
重启
systemctl restart mysqld.service