//查看系统版本shell > cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
//下载YUM库shell > wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
//安装YUM库shell > yum localinstall -y mysql57-community-release-el7-7.noarch.rpm
//安装数据库shell > yum install -y mysql-community-server
//启动MySQL服务shell > systemctl start mysqld.service
//默认空密码shell > mysql -uroot -p
//重置root密码mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
//简单快速重置ROOT数据库密码
最简单的办法,也是最笨的方法,替换mysql数据库中的三个文件/var/lib/mysql/mysql/ //路径
user.frm、user.MYD、user.MYI //替换这三个文件
附几个错误提示解决办法
1、ERROR 1290 (HY000): The MySQL server is running with the –skip-grant-tables option so it cannot execute this statement.
shell> mysql
mysql> set global read_only=0;
mysql> flush privileges;
mysql> quit
shell> /usr/bin/mysql_secure_installation
2、[ERROR] InnoDB: Cannot create log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
shell> cd /var/lib/mysql
shell> mv ibdata1 ibdata1.bak
3、[ERROR] InnoDB: space header page consists of zero bytes in data file ./ibdata1
innodb_flush_log_at_trx_commit = 2 在此后添加下面内容
innodb_flush_method=normal
4、ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)
shell> /usr/bin/mysql_secure_installation