在lnmp環境下忘記mysql密碼解決辦

2021-09-30 11:58:00 字數 667 閱讀 2786

有的時候裝好lnmp後,會忘記mysql密碼,這時候就要通過修改mysql的配置檔案,來跨過資料庫的密碼驗證來實現mysql密碼的重置,具體步驟如下:

1、先確認lnmp的工作狀態: 

# /root/lnmp status ,如果lnmp正在running,則先將其關閉

# /root/lnmp stop

2、進入mysql配置檔案: 

# vim /etc/my.cnf

在[mysqld]的段中加上一句: 

skip-grant-tables

3、啟動lnmp: 

# /root/lnmp start

4、登入並修改mysql的root密碼: 

# /usr/bin/mysql

mysql> use mysql ;

mysql> update user set password = password ( 'new-password' ) where user = 'root' ;

mysql> exit

5、將mysql的登入設定修改回來: 

# vim /etc/my.cnf

將先前在[mysqld]的段中加上的那句刪除: skip-grant-tables

6、重啟lnmp: 

# /root/lnmp restart

CentOS 環境下 搭建 LNMP環境

關掉防火牆,避免實驗中出現伺服器無法訪問的情況 chkconfig iptables off安裝lnmp環境所需的開發包和庫檔案 yum y install ntp make openssl openssl devel pcre pcre devel libpng libpng devel libj...

Lnmp環境下搭建SVN

第一步 安裝svn yum install subversion 第二步 在 usr local下建立svn資料夾並賦予777 chmod r 777 usr local svn 第三步 建立版本庫 svnadmin create usr local svn project 其中project等資料...

centos 下安裝lnmp環境

使用 yum 安裝 nginx yum install nginx yms 修改 etc nginx conf.d default.conf,去除對 ipv6 位址的監聽 示例 etc nginx conf.d default.conf server error page 404 404.html ...