美文网首页
mac配置mysql

mac配置mysql

作者: 一川烟草i蓑衣 | 来源:发表于2020-03-17 11:16 被阅读0次

    mysql官网下载mysql软件Mac版直接安装

    cmd操作mysql:

    mysql目录:/usr/local/mysql

    (1).进入/usr/local/mysql/bin,查看此目录下是否有mysql

    (2).执行vim ~/.bash_profile

    在该文件中添加mysql/bin的目录:

    PATH=$PATH:/usr/local/mysql/bin

    添加完成后,按esc,然后输入wq保存。

    最后在命令行输入source ~/.bash_profile

    现在你就可以通过mysql -u root -p登录mysql了,会让你输入密码                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

    进入mysql后先展示所有数据库:show databases;

    选择某个数据库:use mysql

    展示所有表: show tables

    退出:exit

    远程访问数据库:

    如果出现连接失败:

    mysql -u root -p

        use mysql;

        ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';

    如果无法远程访问:

    默认是localhost访问的,可以用命令查看:

    select host from user where user='root';

    更改为所有ip:

    update user set host = '%'  where user ='root';  

    刷新:

    flush privileges; 

    (3).修改密码

    SET PASSWORD = PASSWORD('new_password');

    相关文章

      网友评论

          本文标题:mac配置mysql

          本文链接:https://www.haomeiwen.com/subject/hsbzehtx.html