# 服务器
[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
复制代码
installation
Lazy copy, go and see this www.cnblogs.com/starof/p/46...
usage
# 查看数据库版本
mysql -V
# 启动数据库
systemctl start mysqld
# 关闭数据库
systemctl stop mysqld
# 自动启动
systemctl enable mysqld
# 禁止
systemctl disable mysqld
复制代码
Common Commands
# 登录数据库
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;
复制代码
data
Q&A
- Ali cloud server 3306 MySQL port connection exception
mysql_secure_installation
If you compare this command to start the server hanging when the card does not move the main database can be reset by the command
Reproduced in: https: //juejin.im/post/5cf4b821f265da1bca51c5b7