基本命令
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; #立即生效