当前位置:Gxlcms > 数据库问题 > mysql 密码初始化

mysql 密码初始化

时间:2021-07-01 10:21:17 帮助过:23人阅读

原文 http://blog.csdn.net/firefoxbug/article/details/7931730

安装mysql

[root@sample ~]# yum -y install mysql-server  ← 安装MySQL [root@sample ~]# yum -y install php-mysql     ← 安装php-mysql  

配置mysql

[root@sample ~]# /etc/init.d/mysqld stop           停止mysql服务 [root@sample ~]# vim /etc/my.cnf                     mysql服务的配置文件

[mysqld]
datadir=/var/lib/MySQL
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
skip-grant-tables #添加这句话,这时候登入mysql就不需要密码
symbolic-links=0

[root@sample ~]# /etc/init.d/mysqld start           启动mysql服务

[root@sample ~]# mysql                                  登入mysql

mysql> USE mysql ;

mysql> UPDATE user SET Password = password(‘new-password‘) WHERE User = ’root’ ;

mysql> flush privileges ;

mysql> quit

在把 /etc/my.cnf 中 skip-grant-tables 注释了,恢复配置文件原样。

[root@sample ~]# /etc/init.d/mysqld restart           启动mysql服务

[root@sample ~]# mysql -u root -p                      输入密码

修改密码

原来的帐号:root,密码:root,修改成 fire

[root@sample ~]# mysqladmin -u root -p password fire

Enter password:

 

mysql 密码初始化

标签:stop   href   set   top   lin   replace   net   改密码   prevent   

人气教程排行