1、卸载旧版本
1.1、查看MySQL rpm -qa|grep mysql rpm -qa|grep mariadb 1.2、卸载MySQL rpm -e --nodeps mysql-5.1.73-7.el6.x86_64 rpm -e --nodeps mysql-connector-odbc-5.1.5r1144-7.el6.x86_64 rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64 rpm -qa|grep mysql 1.3、删除数据目录 ls -l /var/lib|grep mysql rm -rf /var/lib/mysql 数据目录可以备份移走。mysqld服务在初始化时会检查数据目录是否存在:如果数据目录不存在,mysqld则会创建它;如果数据目录存在,且不是空目录(即包含有文件或子目录),mysqld会显示一条错误信息并中止: [ERROR] --initialize specified but the data directory exists. Aborting. 2、安装MySQL5.7 2.1、解压MySQL5.7 tar -xvf mysql-5.7.14-1.el6.x86_64.rpm-bundle.tar顺便提醒,安装环境是CentOS6.5,所以应该选用el6的安装包;CentOS7应该选用el7安装包。如果安装包对应的系统版本不正确,安装时会出现有关glibc的依赖错误
warning: mysql-community-libs-5.7.14-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies: libc.so.6(GLIBC_2.14)(64bit) is needed by mysql-community-libs-5.7.14-1.el7.x86_642.2、按照依赖关系依次安装rpm包
依赖关系依次为common→libs→client→serverrpm -ivh mysql-community-common-5.7.14-1.el6.x86_64.rpmrpm -ivh mysql-community-libs-5.7.14-1.el6.x86_64.rpmrpm -ivh mysql-community-client-5.7.14-1.el6.x86_64.rpmrpm -ivh mysql-community-server-5.7.14-1.el6.x86_64.rpm
开启服务:
service mysqld restart
[root tools]# mysql -uroot -p
Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)在/etc/my.cnf中[mysqld]中添加下面这句话,就可以免密码登录了
skip-grant-tables
mysql -uroot -p
use user;
update mysql.user set authentication_string=PASSWORD('123456') where User='root';
flush privileges;
将刚才在[mysqld]的段中加上的skip-grant-tables删除