mysql裝d盤,下一次裝mysql 試一下這個方法

 2023-10-21 阅读 29 评论 0

摘要:centos7 yum安裝mysql5.7并在root密碼忘記的情況下重設密碼 CentOS7的yum源中默認好像是沒有mysql的。為了解決這個問題,我們要先下載mysql的repo源。 1. 下載mysql的repo源 1 $?wget?http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 2. 安裝mysql-co

centos7 yum安裝mysql5.7并在root密碼忘記的情況下重設密碼

CentOS7的yum源中默認好像是沒有mysql的。為了解決這個問題,我們要先下載mysql的repo源。

1. 下載mysql的repo源

2. 安裝mysql-community-release-el7-5.noarch.rpm包

安裝這個包后,會獲得兩個mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。

3. 安裝mysql

根據步驟安裝就可以了,不過安裝完成后,沒有密碼,需要重置密碼。

4. 重置密碼

修改MySQL的登錄設置:?
# vim /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
保存并且退出vi。

重新啟動mysqld?
# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

登錄并修改MySQL的root密碼?
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> USE mysql ;
Database changed
mysql> UPDATE user SET Password = password ( ‘new-password’ ) WHERE User = ‘root’ ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit

將MySQL的登錄設置修改回來?
# vim /etc/my.cnf
將剛才在[mysqld]的段中加上的skip-grant-tables刪除
保存并且退出vim

重新啟動mysqld?
# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

方式二:

# step1:卸載

[root@codecycle ~]# rpm -qa | grep mysql

mysql-5.1.73-3.el6_5.x86_64

mysql-libs-5.1.73-3.el6_5.x86_64

mysql-server-5.1.73-3.el6_5.x86_64

[root@codecycle ~]# rpm -e --nodeps mysql-5.1.73-3.el6_5.x86_64 mysql-libs-5.1.73-3.el6_5.x86_64 mysql-server-5.1.73-3.el6_5.x86_64

?

?

# step2: 下載yum包,導入本地

[root@codecycle ~]# yum localinstall /usr/local/src/mysql-community-release-el6-5.noarch.rpm

?

?

# step3:安裝

[root@codecycle ~]# yum install mysql-community-server

?

?

# step4:啟動

[root@codecycle ~]# service mysqld start

?

?

# step5:開機啟動

[root@codecycle ~]# chkconfig --list | grep mysqld

mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[root@codecycle ~]# chkconfig mysqld on

?

?

# step6:設置本地登錄密碼

[root@codecycle ~]# mysqladmin -uroot -p password 123456

?

?

# step7:設置遠程登錄密碼

[root@codecycle ~]# mysql -uroot -p123456

mysql> grant all privileges on *.* to root@'%' identified by 'qaz123wsx' with grant option;

mysql> flush privileges;

?

轉載于:https://www.cnblogs.com/jamescr7/p/8252235.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/1/155334.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息