刚跟领导学的小知识点顺手记一下
方法1、
修改 Mysql 配置文件 my.ini
sudo vim /etc/mysql/my.cnf
将 bind-address = 127.0.0.1 这一行注释掉, 即
bind-address = 127.0.0.1
改为:
#bind-address = 127.0.0.1
登陆到本地
use mysql;
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables
SELECT User, Password, Host FROM user; -- 查看现有用户,密码及允许连接的主机
– 下面我们另外添加一个新的 root 用户, 密码为root, 只允许 192.168.8.187连接
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.8.187' IDENTIFIED BY 'root' WITH GRANT OPTION;
或允许所有ip访问
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'root密码';
flush privileges;
重启一下mysql
sudo service mysql restart
xueqy@xueqy:~$ sudo service mysql restart
[sudo] password for xueqy:
mysql stop/waiting
mysql start/running, process 7264
ok。,