1.安装mysql服务器端
sudo apt-get -y install mysql-server
(18.04/20.04不会提示输入密码,默认是没有密码)
2.安装mysql客户端
sudo apt-get -y install mysql-client
3.安装mysql模块
sudo apt-get -y install libmysqlclient-dev
4.验证是否成功
sudo netstat -tap | grep mysql
或者用lsof查看数据库默认端口3306
sudo lsof -i:3306
看到
5.进入mysql
sudo mysql -u root -p //直接按回车登录然后设置密码 mysql> use mysql; mysql> update user set plugin="mysql_native_password", authentication_string=password("123456") where user="root"; mysql> flush privileges; mysql> exit;
重启mysql
sudo service mysql restart
启动/停止/重启mysql
service mysql start
service mysql restart
service mysql stop