ubuntu安装mysql server

2019-11-22  本文已影响0人  GaJiCaptain
  1. 首先更新apt
sudo apt-get update
  1. 看看能安装的mysql版本
apt-cache search mysql | grep mysql-server
  1. 安装mysql-server,过程中需要确认安装一次,设置两次root密码
sudo apt-get install mysql-server-5.7

安装过程中需要设定两次root密码

  1. 测试安装是否成功,输入下行命令,再按照提示输入密码
mysql -u root -p
  1. 如果需要远程访问,远程授权
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密码' WITH GRANT OPTION;
  1. 如果需要远程访问,就需要修改配置文件:
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

修改其中一行
bind-address=127.0.0.1

bind-address=0.0.0.0

  1. 最后重启mysql服务
sudo service mysql restart
上一篇下一篇

猜你喜欢

热点阅读