1. 程式人生 > >ubuntu 18.04用apt安裝mysql-server

ubuntu 18.04用apt安裝mysql-server

應該 get client add 驗證方式 then ice 重啟 sta

mysql5.7安裝完成後普通用戶不能進mysql

原因:root的plugin被修改成了auth_socket,用密碼登陸的plugin應該是mysql_native_password,直接用root權限登錄就不用密碼,修改root密碼和登錄驗證方式。

#移除之前安裝的mysql
sudo apt-get --purge remove mysql-server mysql-common mysql-client

#安裝mysql-server
sudo apt-get install mysql-server mysql-common mysql-client

#更改mysql root賬戶認證模式
mysql
select user, plugin from mysql.user;


update mysql.user set authentication_string=PASSWORD(‘密碼‘), plugin=‘mysql_native_password‘ where user=‘root‘;
flush privileges;
exit

#重啟mysql-server
service mysql restart

#配置root遠程登陸
grant all on *.* to root@‘%‘ identified by ‘密碼‘ with grant option;
flush privileges;
exit

#修改偵聽地址127.0.0.1為0.0.0.0
vi /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0

ubuntu 18.04用apt安裝mysql-server