Centos6.7 通过yum安装mysql5.7

一 更换yum
1备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2更新阿里yum源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
3 查看cd /etc/yum.repos.d/
4 yum clean all
5 yum makecache
二 下载配置mysql的yum源的rpm包
wget https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm
安装用来配置mysql的yum源的rpm包
rpm -Uvh mysql57-community-release-el6-9.noarch.rpm
安装成功后在/etc/yum.repos.d/下会多出几个mysql的yum源的配置
[root@zat2 yum.repos.d]# ls
CentOS-Base.repo CentOS-fasttrack.repo mysql-community.repo
CentOS-Base.repo.backup CentOS-Media.repo mysql-community-source.repo
三 安装mysql
[root@zat2 yum.repos.d]# rpm -qa | grep mysql
[root@zat2 yum.repos.d]# yum install mysql-community-server
四 开启mysql
[root@zat2 yum.repos.d]# service mysqld restart
停止 mysqld: [确定]
初始化 MySQL 数据库: [失败]
[root@zat2 yum.repos.d]# service mysqld restart
停止 mysqld: [确定]
正在启动 mysqld: [确定]
[root@zat2 yum.repos.d]# ps -ef | grep mysql
五报错处理
[root@zat2 ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@zat2 ~]# vi /etc/my.cnf
在[mysqld]后面任意一行添加“skip-grant-tables”用来跳过密码验证的过程
[root@zat2 ~]# service mysqld restart
停止 mysqld: [确定]
正在启动 mysqld: [确定]
[root@zat2 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22 MySQL Community Server (GPL)
mysql设置密码
[root@zat2 yum.repos.d]# mysqladmin -uroot -p password 'zat'
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin:
You cannot use 'password' command as mysqld runs
with grant tables disabled (was started with --skip-grant-tables).
Use: "mysqladmin flush-privileges password '*'" instead
[root@zat2 yum.repos.d]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.22 MySQL Community Server (GPL)

猜你喜欢

转载自www.cnblogs.com/zhanzhan/p/9074602.html