- 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
mac中老是报错,留作备忘GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'root' WITH GRANT OPTION;
-
远程思路
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启动
2.关闭ps -ef | grep -i mysql
3.my.cnf配置文件的位置,一般在/etc/my.cnf,有些版本在/etc/mysql/my.cnf,配置文件中,增加2行代码service mysql stop
4.启动[mysqld] skip-grant-tables
5.进入service mysqld start
mysql -u root
6.修改密码
7.删除增加的配置,重启