Mysql安装

来源:互联网 发布:神秘博士 知乎 编辑:程序博客网 时间:2024/06/16 11:23

原始地址:http://blog.onlywan.cc/14975769061187.html

Mysql安装

    • Mysql安装
      • 安装命令
      • apt-get 安装mysql57
      • 安装mysql57后无root密码无法登陆解决

安装命令

#ubuntu$apt-get update$apt-get install mysql-server mysql-client默认安装mysql5.5

apt-get 安装mysql5.7

#step1:添加mysql apt源#   1.下载apt源,官网地址:http://dev.mysql.com/downloads/repo/apt/(需要注册用户,csdn下载地址:http://download.csdn.net/detail/wan353694124/9871670)#   2.安装源(PATH为你的路径,version-specific-package-name为下载的名字)$ sudo dpkg -i /PATH/version-specific-package-name.deb#   3.选择mysql版本等#   4.执行apt-get update$ sudo apt-get update#step2:安装mysql$ sudo apt-get install mysql-server

参考:https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/#apt-repo-setup

安装mysql5.7后,无root密码,无法登陆解决

# 关闭mysql$ sudo service mysql stop# 运行mysql无密码启动$ sudo mysqld_safe --skip-grant-tables &# 为了安全,可以这样启动,禁止远程连接$ sudo mysqld_safe --skip-grant-tables --skip-networking &# 启动后登录mysql$ mysql# 更改密码mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';mysql> flush privileges;mysql> quit;# 重启mysql服务$ sudo service mysql restart