# 服务器
[root@ww ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
# mysql版本
[root@wangwei ~]# mysql -V
mysql Ver 14.14 Distrib 5.6.42, for Linux (x86_64) using EditLine wrapper
复制代码
安装
懒的复制了,去这看吧www.cnblogs.com/starof/p/46…
用法
# 查看数据库版本
mysql -V
# 启动数据库
systemctl start mysqld
# 关闭数据库
systemctl stop mysqld
# 自动启动
systemctl enable mysqld
# 禁止
systemctl disable mysqld
复制代码
常用命令
# 登录数据库
mysql -u root -p
# 查看数据库列表
show databases;
# 创建数据库
create database db_name;
# 切换库
use db_name;
# 查看当前所在的库
select database();
# 删除库
drop database db_name;
# 显示数据库中的表
show tables;
# 添加用户
create user 用户名称 identified by 密码
# 授权某一个数据库的所有权限给指定用户
grant all on 数据库名称 to 用户名称
# 显示一个数据库中的表
show tables from test;
# 查看用户的权限
show grants for 用户名;
# 查看数据库用户列表
use mysql
select host,user from mysql.user;
复制代码
资料
Q&A
- 阿里云服务器3306端口MySQL连接异常
mysql_secure_installation
该命令比较吊如果你 启动服务器的时候卡主不动了 可以通过该命令重置数据库
转载于:https://juejin.im/post/5cf4b821f265da1bca51c5b7