centos7 rpm 安装MySQL5.6

时间:2021-03-07 07:27:13

系统centos7,安装MySQL,出错,百度了一大堆,几乎都是通过yum安装的MySQL,我想说的是,通过yum自动安装的话系统自己会帮你做很多事情,相关联的包也会下下来,相当于替你省去了很多事情,但是Linux作为服务器,有些服务器是不能接外网的,特别是*机构,所以通过RPM安装就显得尤为重要,你需要自己去下载包文件来安装配置。

其次centos7的特性,网上找了很多有关于centos系统的很少提及centos7,centos7自带mariaDB-lib包,安装之前请先运行

rpm -qa | grep maria

将找到的有关于maria的所有东西删掉,再运行

rpm -qa | grep mysql

rpm -qa | grep MySQL

将有关于MySQL的所有东西也删掉,强制删除命令

rpm -e --nodeps mysql57-community-release-el7-8.noarch.........

删除干净后,开始安装

rpm -ivh mysql57-community-release-el7-8.noarch.rpm

参数-ivh将安装信息打印出来

安装完毕后运行

systemctl start mysql

# mysqladmin -uroot -p password 'newpassword'

Enter password:

mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user 'root'@'localhost' (using password: YES)'

解决办法:

# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit

# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>