Linux下mysql的安装步骤
(1)检查旧版本mariadb
rpm -qa|grep mariadb
(2)删除旧版本
yum -y remove mariadb-libs-5.5.64-1.el7.x86_64
(3)因为minimal安装所以wget不能用
yum search wget 找安装源
(4)设置rpm镜像源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
(5)rpm安装
rpm -ivh mysql-community-release-el7-5.noarch.rpm 下载mysql
yum -y install mysql-server 安装mysql
(6)启动mysql服务
systemctl start mysql
(7)首次免密登录:mysql 回车进入
进入mysql库:use mysql
修改密码:
虚拟机内连接:update user set password=password(PASS_STR) where user=’root’;
命令:update user set password=password(‘root’) where user=’root’;
开启root外网连接:grant all on . ro root@’%’ identified by ‘PASS_STR’;
命令:rant all on . ro root@’%’ identified by ‘root’;
重启服务后自动关闭免密登录:reboot(重启虚拟机)
登录:
- mysql -uroot -proot
- mysql -uroot -p
root