安装mysql
配置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>USEmysql;
mysql>UPDATEuserSETPassword=password(‘new-password‘)WHEREUser=’root’;
mysql>flushprivileges;
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: