MySql數(shù)據(jù)庫栈幸,允許遠程登錄愤估,任何主機上都能登錄MySQL數(shù)據(jù)庫
1、登錄mysql客戶端
[root@node1 ~]# mysql -uroot -p000000
2速址、顯示數(shù)據(jù)庫
mysql>show databases;
3玩焰、使用mysql數(shù)據(jù)庫
mysql>use mysql;
4、展示mysql數(shù)據(jù)庫中的所有表
mysql>show tables;
5芍锚、展示user表的結(jié)構(gòu)
mysql>desc user;
6昔园、查詢user表
mysql>select user,host,authentication_string from user;
尖叫提示:mysql5.6密碼使用的是password字段
7蔓榄、修改user表,把Host表內(nèi)容修改為%
mysql>update user set host='%' where user='root' and host='localhost';
尖叫提示:代替方法
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '000000' WITH GRANT OPTION;
8默刚、刪除root用戶的其他host
mysql> delete from user where user='root'and host!='%';
mysql> delete from user where user=''and host!='%';
9甥郑、刷新
mysql>flush privileges;
10、退出
mysql> quit;
11羡棵、設(shè)置開機啟動
查看mysql開機啟動的狀態(tài)
[root@node1 ~]# chkconfig mysql --list
設(shè)置mysql開機啟動
[root@node1 ~]# chkconfig mysql on
設(shè)置mysql開機不啟動
[root@node1 ~]# chkconfig mysql off
尖叫提示:使用root用戶設(shè)置或使用sudo命令
mysql5.7版本開機啟動/禁用的命令是
systemctl enable mysqld
systemctl disable mysqld
systemctl daemon-reload
也可以把啟動命令寫入到rc.local文件中
echo 'service mysql start' >> /etc/rc.local