1、Linux mysql安装
(1)清理环境》》清理已安装的mysql/mariadb服务
#查看已经安装的mysql/mariadb
rpm -qa |grep -i mysql
rpm -qa |grep -i mariadb
rpm -e --nodeps 加上上面搜索到的结果,把mariadb/mysql包清掉
(2)在线安装
#下载mysql5.7,更多版本https://repo.mysql.com
wget https://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
#添加本地repo
rpm -ivh mysql57-community-release-el7-10.noarch.rpm
#安装
yum check-update
yum update
yum install mysql mysql-server -y
(3)离线安装
(4)下载地址:
https://downloads.mysql.com/archives/community/
(5)解压
tar -xvf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
(6)安装
rpm -ivh mysql-community-common-5.7.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm
(7)启动
#启动,开机启动 mysql
systemctl start mysqld
systemctl enable mysqld
systemctl status mysqld
(8)获取自动生成的临时密码
grep 'temporary password' /var/log/mysqld.log
(9)登录
mysql -u root -p
(10)修改密码并授权
ALTER USER 'root'@'localhost' IDENTIFIED BY '密码';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '密码' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION; FLUSH PRIVILEGES;