数据库
首页 > 数据库> > Linux安装Mysql

Linux安装Mysql

作者:互联网

1.安装wget

yum install -y wget

2.备份

cd /etc/yum.repos.d/

mv CentOS-Base.repo CentOS-Base.repo_bak

3.更换阿里云yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

4. 清除YUM缓存并建立缓存

yum clean all

yum makecache

5.查询mariadb并卸载

rpm -qa | grep mariadb

rpm -e --nodeps mariadb-libs-5.5.65-1.el7.x86_64(复制当前环境的mysql)

6.下载mysql的repo源并安装rpm包

cd /opt/

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

7. 安装mysql

yum install mysql-server -y

8.授予权限

chown -R root:root /var/lib/mysql

chown root /var/lib/mysql/

9.重启mysql数据库

service mysqld restart

10.登录mysql数据库并授权

mysql -u root -p

use mysql

update user set Password = password('ok') where User='root';

GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "ok";

 

11.使配置生效并退出

flush privileges;

exit

12.安装vim并设置字符集

yum install -y vim

vim /etc/my.cnf

添加

character-set-server=utf8

13.重启mysql

service mysqld restart

14.登录mysql数据库

mysql -uroot -pok

标签:rpm,Mysql,Linux,repo,yum,mysql,wget,root,安装
来源: https://www.cnblogs.com/lyabbk/p/16163275.html