亲测小白系列之-mysql安装,远程访问

本文详细介绍在Mac和Linux环境下安装及配置MySQL的过程,包括使用brew和yum进行安装,配置远程访问,解决常见错误,以及如何设置和更改root账户密码。
  • mac mysql安装
    brew install mysql
    mysql.server start
    use mysql
    select host,user,plugin,authentication_string from user;
    update user set host = '%' where user = 'root';
    FLUSH PRIVILEGES;
    ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
    netstat -an|grep 3306
    修改/etc/mysql/my.cnf文件,brew修改/usr/local/etc/my.cnf
    注释bind-address = 127.0.0.1
    vi /usr/local/etc/my.cnf
    mysql.server restart
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'root' WITH GRANT OPTION;mac中老是报错,留作备忘
  • 远程思路
    1.看清报错提示,不要盲目
    2.查看root用户host,以及加密方式
    3.查看mysql监听,修改配置文件绑定本地和防火墙
  • linux 安装
    wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
    rpm -ivh mysql-community-release-el7-5.noarch.rpm
    yum install mysql-community-server
    service mysqld restart
    
    初次安装mysql,root账户没有密码
    设置密码
    set password for 'root'@'localhost' =password('password');
  • 配置mysql 编码 远程
    mysql配置文件为/etc/my.cnf
    最后加上编码配置
    default-character-set =utf8
    远程访问命令
    grant all privileges on *.* to root@'%'identified by 'password';
  • 修改密码新老版本5.7
    use mysql;
    update user set password=password('123') where user="root";
    update user set authentication_string=password('123') where user="root";
    flush privileges;
    
  • 忘记密码
    1.检查mysql启动ps -ef | grep -i mysql
    2.关闭service mysql stop
    3.my.cnf配置文件的位置,一般在/etc/my.cnf,有些版本在/etc/mysql/my.cnf,配置文件中,增加2行代码
    [mysqld]
    skip-grant-tables
    
    4.启动service mysqld start
    5.进入mysql -u root
    6.修改密码
    7.删除增加的配置,重启
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值