注意別安裝8,8配置過高了 $: sudo apt-get install mysql-server or $: sudo apt-get install mysql-server-5.7
$: sudo netstat -tap | grep mysql
啓用mysql服務 $: sudo service mysql start 關閉mysql 服務 $: sudo service mysql stop 重啓mysql 服務 $: sudo service mysql restart
$: ps aux | grep mysql
root 用戶能夠免密碼登入,直接回車便可mysql
$: mysql -u root -p password:sa (默認密碼) > show databases;
> use mysql; > UPDATE user SET mysql_native_password=mysql_native_password("123456") WHERE user='root'; > flush privileges; (刷新,使表生效) > quit; (退出) $: sudo service mysql restart; $: mysql -u root -p (驗證新密碼)
$: mysql -u root -p password > update user set host='%' where user='root' and host='你的ip'; > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的mysql密碼' WITH GRANT OPTION; > flush privileges; (刷新,使表生效)
$: sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf 註釋 # bind-address = 127.0.0.1: :wq! (保存退出) $: sudo service mysql restart (重啓mysql)