版本更新,原來user裏的password字段已經變動爲authentication_stringmysql
版本更新 緣故,好多網上的教程都不適用了,甚至連官網的文檔也不是可以順利操做的。sql
若是 MySQL 正在運行,首先殺之: killall -TERM mysqld。數據庫
運行mysqld_safe --skip-grant-tables &ide
若是此時不想被遠程鏈接:mysqld_safe --skip-grant-tables --skip-networking &ui
使用mysql鏈接server加密
更改密碼:update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';server
*特別提醒注意的一點是,新版的mysql數據庫下的user表中已經沒有Password字段了教程
而是將加密後的用戶密碼存儲於authentication_string字段ip
mysql> flush privileges;文檔
mysql> quit;
修改完畢。重啓
killall -TERM mysqld。
mysqld_safe &
而後mysql就能夠鏈接了
可是此時操做彷佛功能不徹底,還要alter user...
alter user 'root'@'localhost' identified by '123';
網文說醬紫也能夠:set password for 'root'@'localhost'=password('123');
cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql