Brew 卸载MySql以及安装Mysql

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liuxw1/article/details/81434005

卸载:

    


1.brew remove mysql

 

2.brew cleanup

 

3.launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

 

4.rm ~/Library/LaunchAgents/com.mysql.mysqld.plist

 

5.sudo rm -rf /usr/local/var/mysql

 

 

安装


  1. 使用homebrew一键安装相应的包,因为homebrew会检测最新的版本,所以下载的mysql版本是5.7.*版本
    最近安装的时候最新版本更新到8.x版本,

    关于homebrew的安装,链接

    ➜ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    搜索一下mysql版本:

    brew search mysql
    
    ==> Formulae
    automysqlbackup       mysql-cluster         mysql-search-replace  mysql@5.7
    mysql                 mysql-connector-c     mysql-utilities       mysqltuner
    mysql++               mysql-connector-c++   mysql@5.5
    mysql-client          mysql-sandbox         mysql@5.6
    
    
    ==> Casks
    homebrew/cask/mysql-connector-python         homebrew/cask/navicat-for-mysql
    homebrew/cask/mysql-shell                    homebrew/cask/sqlpro-for-mysql
    homebrew/cask/mysql-utilities
    

    安装mysql:

    ➜ brew install mysql@5.7
    ➜ ln -sfv /usr/local/opt/mysql@5.7/*.plist ~/Library/LaunchAgents
    ➜ mysql.server start
    

    如果mysql.server startzsh: command not found: mysql.server的话,配置一下环境变量,如果是卸载重新切换版本的话brew link mysql@5.7

    上面的第二步骤是设置开机启动

    登录

    ➜ mysql -uroot
    
    show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.00 sec)
    

    修改root密码

    use mysql
    update user set authentication_string = password('root') where User='root';
    Query OK, 1 row affected, 1 warning (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 1
    

    以前修改mysql密码字段是Password这个字段,但是mysql5.7没有这个字段而是使用了authentication_string替代

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    

    如果操作过程中报下面的错误

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    

    那么使用首先关闭mysql服务,然后以安全模式启动
    mysql.server start --skip-grant-tables

最后可以参考:https://blog.csdn.net/cheng649090216/article/details/79246333

展开阅读全文

没有更多推荐了,返回首页