安装mysql,安装过程中会要求输入2次密码
sudo apt-get install mysql-server
启动mysql,默认是自动启动
sudo service mysql start
关闭mysql
sudo service mysql stop
重启mysql
sudo service mysql restart
mysql无法远程访问,执行以下代码
nano /etc/mysql/my.cnf
注释 #bind-address =127.0.0.1
Ctrl+o保存 确认 Ctrl+x退出
mysql -uroot -p 先登录mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
重启mysql
sudo service mysql restart