基本命令
Author : Janloong Do_O
重啓
sudo /etc/init.d/mysql restart
啓動mysql:
方式一:sudo /etc/init.d/mysql start
方式二:sudo start mysql
方式三:sudo service mysql start
停止mysql:
方式一:sudo /etc/init.d/mysql stop
方式二:sudo stop mysql
方式san:sudo service mysql stop
重啓mysql:
方式一:sudo/etc/init.d/mysql restart
方式二:sudo restart mysql
方式三:sudo service mysql restart
外網訪問配置用戶
grant all on *.* to yjsh@'%' identified by 'yjsh';
grant all on *.* to root@'%' identified by 'root';
GRANT ALL PRIVILEGES ON *.* TO 'yjsh'@'%' IDENTIFIED BY 'yjsh@aliyun' WITH GRANT OPTION;
flush privileges;
grant all on bingdg-demo.* to 'yjsh'@'%' identified by 'yjsh';
GRANT ALL PRIVILEGES ON bingdg-demo.* TO 'yjsh'@'%' IDENTIFIED BY 'yjsh' WITH GRANT OPTION;
修改用戶密碼
use mysql;
mysql> update user set password=password('yjsh123456') where user='root' and host='%';
mysql> flush privileges;
5.7
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
修改鏈接
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
註釋其中的:bind-address = 127.0.0.1配置或者修改爲bind-address = 0.0.0.0
最大傳輸設置
max_allowed_packe
配置相關
查看數據庫編碼
show variables like 'char%';
查看數據庫慢查詢設置
show variables like "%slow_query%"
時區設置
mysql時區相差8 14個小時
show variables like "%time_zone%"
set global time_zone = '+8:00'; ##修改mysql全局時區爲北京時間,即我們所在的東8區
set time_zone = '+8:00'; ##修改當前會話時區
flush privileges; #立即生效