mysql基本操作

  • 安装(版本5.7)

    • sudo apt-get install mysql-server
      sudo apt-get install mysql-client
      sudo apt-get install libmysqlclient-dev
      
      sudo netstat -tap | grep mysql
      
    • sudo vim /etc/mysql/debian.cnf # 查看默认登陆密码
      mysql -u debian-sys-maint -p # 登录
      
      update mysql.user set authentication_string=password('password') where user='root'and Host = 'localhost'; # 更改密码
      
      # 新建mysql账户
      CREATE USER 'root_sql'@'localhost' IDENTIFIED BY 'yourpasswd';
      GRANT ALL PRIVILEGES ON *.* TO 'root_sql'@'localhost' WITH GRANT OPTION;
      FLUSH PRIVILEGES;
      
    • # 删除mysql
      sudo apt-get autoremove --purge mysql-server-5.7
      sudo apt-get remove mysql-server
      sudo apt-get autoremove mysql-server
      sudo apt-get remove mysql-common
      
      # 清理残余数据
       dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
      
    • # 重启数据库
      service mysql restart
      
    • # 设置远程连接
      sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
      
      # 注释掉bind-address = 127.0.0.1
      
      # 进入mysql服务,执行授权命令
      grant all on *.* to root@'%' identified by '你的密码' with grant option;
      flush privileges;
      
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容