问题:grant all privileges on *.* to 'root'@'%' with grant option;给用户授予远程登录权限报错
低版本用这个命令没问题,但是8.0以上版本就不行了
3 添加lower_case_table_names=1
修改 /etc/my.cnf
在[mysqld]增加
lower_case_table_names=1
4 初始化mysql
sudo mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql --basedir=/var/lib/mysql --datadir=/var/lib/mysql ;
mysqld --initialize --lower_case_table_names=1
解决方案
修改密码策略
set global validate_password_policy=0;
创建用户并赋权
CREATE USER `binlog`@`192.168.%` IDENTIFIED BY '7758521Yzh';
grant replication slave on *.* to 'itcast'@'192.168.%';
1.修改用户密码 ALTER USER root@'%' IDENTIFIED WITH mysql_native_password BY '7758521Yzh'; alter user root@localhost identified by '123456'; 2.切换到mysql库修改root用户的host,并给用户赋予远程权限 use mysql; update user set host='%' where user ='root'; flush privileges; grant all privileges on *.* to 'root'@'%' with grant option;
问题:由于初始化MySQL,忘记了密码,修改my.cnf配置skip-grant-table跳过密码验证启动mysql,使用netstat -nlt查询mysql监听的端口发现查询不到
进入mysql执行命令,发现mysql的端口是0
mysql> show variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 0 |
+---------------+-------+
1 row in set, 1 warning (0.05 sec)
具体原因查看这个文章:mysqld使用--skip-grant-tables选项启动后,端口为“0”解决办法 - 哑吧 - 博客园