$ sudo apt-get install mysql-server $ sudo apt install mysql-client $ sudo apt install libmysqlclient-dev
檢查是否安裝成功mysql
$ netstat -tap | grep mysql
若安裝成功會有以下輸出sql
注意: 若是出現command not found: netstat
,請先安裝 net-tools,而後再檢查是否成功:shell
sudo apt-get install net-tools
編輯MySQL的配置文件vim
$ vim /etc/mysql/mysql.conf.d/mysqld.cnf
把下面的內容註釋ide
bind-address = 127.0.0.1
以root權限進入MySQL命令行,執行開啓權限命令,本示例中MySQL中用戶與密碼皆爲rootspa
grant all on *.* to root@'%' identified by 'root' with grant option; flush privileges;
重啓MySQL命令行
$ sudo /etc/init.d/mysql restart