mysql初始化後修改密碼及賦權

leixue0906發表於2015-06-18
mysql初始化後修改密碼及賦權

在丟失root密碼的時候,可以這樣


方法一:
# /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>


更改密碼:
update user set password=PASSWORD('123456') where USER='root';

遠端連線賦權
grant all PRIVILEGES on mysql.* to root@'192.168.166.102' identified by '123456';

grant all PRIVILEGES on *.* to root@'%' identified by 'mysql';





my.cnf 檔案資訊


[client]
default-character-set=utf8
[mysqld]
lower_case_table_names=1
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
default-character-set=utf8
init_connect='SET NAMES utf8'
[mysql]
default-character-set=utf8
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26845409/viewspace-1704087/,如需轉載,請註明出處,否則將追究法律責任。

相關文章