mysql5.7 服务启动重启命令,增加数据库用户,授权,远程访问,区分大小写查看与配置

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;

你可能感兴趣的:(linux服务器,数据库,ubuntu,mysql,linux,数据库,运维)