注意: 有的Centos版本默认安装了mariadb, 可以先将其卸载
检查mariadb是否安装
yum list installed | grep mariadb
卸载mariadb( all )
yum -y remove mariadb*
1.
网上下载MySQL的yum源
wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2.
使用rpm安装下载的mysql的yum源
rpm -ivh 下载下来的.rpm文件
3.
安装mysql-community-server服务
yum install mysql-community-server
4.
启动mysqld服务
systemctl start mysqld
初次安装, root用户是没有密码的, 直接敲入:mysql, 进入mysql
设置root密码:
set password for 'root'@'localhost' =password('New_password');
创建一个可用于远程访问的用户(其中%为可远程连接的地址,%表示所有, 也可写成localhost或者其他可批准链接的地址):
grant all privileges on *.* '账户名'@'%' identified by '密码' with grant option;