今天在ubuntu和deepin中安裝mysql,發現過程當中麼有要求配置密碼,安裝完成後怎麼都登陸不上去,在deeping論壇看到解決方案記錄一下mysql
deeping用apt安裝的mysql,須要修改的是/etc/mysql/mariadb.conf.d/下的50-server.cnf文件sql
ubuntu用apt安裝的mysql,須要修改的是/etc/mysql/mysql.conf.d/下的mysqld.cnf文件數據庫
步驟:ubuntu
1.先在配置文件中添加一行 skip-grant-tables,重啓服務server
2.直接輸入mysql登陸進去ip
3.執行下面語句,若是是deepin記得use mysql數據庫string
update mysql.user set plugin="mysql_native_password" where user="root";(這句必須)
update mysql.user set authentication_string=password('這裏是你的密碼') where user='root'and Host = 'localhost';it
4.exit 重啓服務,而後正常登陸就能夠了io