linux mysql相关命令
登录数据库:
mysql -u root -pPASSWORD
重启:
systemctl restart mysqld
启动:
service mysql start
停止:
service mysql stop
mysql内的命令
查看端口号:
show global variables like 'port';
查看是否区分大小写(1不区分,0区分):
show variables like '%case_table%';
授权给所有主机host可访问:
grant all privileges on *.* to "用户名"@"%" identified by "密码";
刷新权限:
flush privileges;
用户相关权限
创建用户:
create user '用户名'@'ip地址' identified by '密码';
查看用户
select user,host from mysql.user WHERE user='xiaoming';
授权
grant insert,delete,select,alter ON DB.* TO 'xiaoming'@'localhost';
查看授权
show grants for 'xiaoming'@'localhost';
设置密码
set password for xiaoming@localhost = password('123456');
远程连接需注释或更改bind端口为0.0.0.0 和 查看修改数据库是否区分大小写
解决方案1:
配置文件可能在cd /etc/mysql/mysql.conf.d/
下
也可能在vi /etc/my.cnf
在[mysqld]下修改或添加bind-address=0.0.0.0
lower_case_table_names = 1
1代表不区分,0代表区分
解决方案2:
授权给所有主机host可访问:
grant all privileges on *.* to "用户名"@"%" identified by "密码";
刷新权限:
flush privileges;