1.使用apt-get查找当前可用的mysql版本.
apt-cache search mysql

返回的结果集为:

ubuntu上mysql的安装以及基本用法

 

2.通过结果集找到最新可用的服务端是mysql-server,安装mysql-server

sudo apt-get install mysql-server

 

按提示安装即可(中间会提示设置root口令)。


3.测试是否安装正确

# 登录
mysql -uroot -p

出现以下界面即正确安装

ubuntu上mysql的安装以及基本用法

 

 

4.mysql服务的启动与停止

安装完后mysql服务默认是启动状态。

停止服务

sudo /etc/init.d/mysql stop

启动服务

sudo /etc/init.d/mysql start

重启mysql

sudo /etc/init.d/mysql restart

 

5.让外网可以访问mysql
改mysql配置文件
sudo vi /etc/mysql/my.cnf
找到该行并注释掉
#bind-address           = 127.0.0.1
保存修改后的my.cnf文件(ctrl+zz)
重启mysql
sudo /etc/init.d/mysql restart


6.分配mysql用户

mysql -uroot -p
mysql>grant all privileges on 数据库名.* to '账号'@'%' identified by '口令';
mysql>flush privileges;
mysql>exit

相关文章:

  • 2021-12-09
  • 2022-12-23
  • 2021-09-17
  • 2021-10-27
  • 2021-11-20
  • 2021-05-09
  • 2021-11-30
  • 2022-01-05
猜你喜欢
  • 2021-04-11
  • 2021-09-14
  • 2022-01-13
  • 2021-11-21
  • 2022-12-23
  • 2022-01-24
相关资源
相似解决方案