- 注意版本和此次更新时间 2017-12-03 版本:mysql-5.7.20-1.el6.x86_64 环境:linux6.x
-
官方下载地址:
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar
-
解压:
tar -xvf mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar
-
卸载之前的版本
rpm -qa | grep -i mysql
rpm -e xxxxx [之前安装的版本] --nodeps 要卸载的mysql版本
-
按照步骤来安装就好
1.rpm -ivh mysql-community-libs-5.7.20-1.el6.x86_64.rpm --nodeps --force
2.rpm -ivh mysql-community-devel-5.7.20-1.el6.x86_64.rpm --nodeps --force
3.rpm -ivh mysql-community-client-5.7.20-1.el6.x86_64.rpm --nodeps --force
4.rpm -ivh mysql-community-server-5.7.20-1.el6.x86_64.rpm --nodeps --force
-
修改密码 (有点特殊 )
1.找到my.cnf | 本机 /etc/my.cnf
2.[mysqld]#下添加
skip-grant-tables=1 #不用验证
3.
mkdir -p /var/run/mysqld/
开启mysql /etc/init.d/mysqld start|本机默认地址
4.进入并修改(依次命令)
1. mysql -uroot -p;
2.use mysql
3.update user set authentication_string = password('123456'), password_expired = 'N', password_last_changed = now() where user = 'root';
5.my.cnf | 本机 /etc/my.cnf 里面删除skip-grant-tables=1
6.执行远程授权
1.FLUSH PRIVILEGES;
2.GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
3.FLUSH PRIVILEGES;
6.测试
mysql -uroot -p123456 -e "show databases;";
7.Linux下设置mysql自动启动
1、将服务文件拷贝到init.d下,并重命名为mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
2、赋予可执行权限
chmod +x /etc/init.d/mysqld
3、添加服务
chkconfig --add mysqld
4、显示服务列表
chkconfig --list
如果看到mysql的服务,并且3,4,5都是on的话则成功,如果是off,则键入
chkconfig --level 345 mysqld on
5、重启电脑
reboot
6、验证
netstat -na | grep 3306
如果看到有监听说明服务启动了
8.OK收工;
遇到的错误总结:
1.默认提示需要输入校验码
[root@xxxxxx tool]# rpm -ivh mysql-community-devel-5.7.20-1.el6.x86_64.rpm
warning: mysql-community-devel-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
解决:(去掉校验安装)
rpm -ivh mysql-community-devel-5.7.20-1.el6.x86_64.rpm --nosignature
2.木有安装 mysql-community-libs-5.7.20-1.el6.x86_64.rpm
[root@xxxxxx tool]# rpm -ivh mysql-community-devel-5.7.20-1.el6.x86_64.rpm --nosignature
error: Failed dependencies:
libmysqlclient.so.20()(64bit) is needed by mysql-community-devel-5.7.20-1.el6.x86_64
mysql-community-libs(x86-64) >= 5.7.9 is needed by mysql-community-devel-5.7.20-1.el6.x86_64
解决:
rpm -ivh mysql-community-libs-5.7.20-1.el6.x86_64.rpm --nosignature
3.权限问题