Login
User: root
Password: root
Initialize
mysqld --initialize --console;
mysqld install;
net start mysql
修改密碼
use mysql;
alter user user() identified by "password";
Grant
創(chuàng)建賬戶
create user 'root'@'172.16.10.203' identified by 'password';
use mysql;
update user set host = '%' where user = 'root' and host='localhost';
賦予權(quán)限
with grant option這個(gè)選項(xiàng)表示該用戶可以將自己擁有的權(quán)限授權(quán)給別人
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
改密碼&授權(quán)超用戶
flush privileges 命令本質(zhì)上的作用是將當(dāng)前user和privilige表中的用戶信息/權(quán)限設(shè)置從mysql庫(MySQL數(shù)據(jù)庫的內(nèi)置庫)中提取到內(nèi)存里
flush privileges;
服務(wù)器遠(yuǎn)程訪問
Linux下服務(wù)器開放3306端口,配置mysql停撞。
- 查看3306端口是否正常
root@node1:~# netstat -an | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
注意:現(xiàn)在的3306端口綁定的IP地址是本地的127.0.0.1
- 修改Mysql配置文件(注意路徑蛤克,跟之前網(wǎng)上的很多版本位置都不一樣)
root@node1:~# vim /etc/mysql/mysql.conf.d/mysqld.cnf
找到
bind-address = 127.0.0.1
前面加#注釋掉
- 重啟Mysql
root@node1:~# /etc/init.d/mysql restart
[ ok ] Restarting mysql (via systemctl): mysql.service.
- 再次查看端口信息
root@node1:~# netstat -an | grep 3306
tcp6 0 0 :::3306 :::* LISTEN
- 通過端口掃描命令結(jié)果:
3306/tcp open mysql