安装MySQL
添加mysql源

[root@localhost ~]# rpm -ivh http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm

安装mysql
[root@localhost ~]# yum -y install mysql-community-server

启动mysql、检查状态、设置为开机自启
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl status mysqld
[root@localhost ~]# systemctl enable mysqld

第一次启动mysql,会在日志文件中生成root用户的一个随机密码,使用下面命令查看该密码
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log

修改root用户密码
[root@localhost ~]# mysql -u root -p
Enter password:

mysql> alter user 'root'@'localhost' identified by 'p@$$w0rd';

创建数据库(数据库名为:test)
mysql> create database test;

使用test数据库
mysql> use crashcourse;

执行sql脚本(使用source命令)
mysql> source /root/MySQLCrashCourse/create.sql;
mysql> source /root/MySQLCrashCourse/populate.sql;

查看可用数据库的列表
mysql> show databases;

查看当前数据库内可用表的列表
mysql> show tables;

显示表列(表名:customers)
mysql> show columns from customers;

显示服务器错误或警告消息
mysql> show errors;
mysql> show warnings;

安全管理
不应该在日常的MySQL操作中使用root

获得所有账号列表
mysql> use mysql;
mysql> select user from user;

创建用户账号
mysql> create user test1 identified by 'p@$$w0rd';

重命名用户账号
mysql> rename user test1 to test2;

删除用户账号
mysql> drop user test;

查看用户账号权限
mysql> show grants for test;

给用户账号授予权限
mysql> grant select on crashcourse.* to test;

撤销用户权限
mysql> revoke select on crashcourse.* from test;

更改用户口令
set password for test = password('n3w p@$$w0rd');

设置自己的口令
set password = password('n3w p@$$w0rd');

汉语支持:

vi /etc/my.cnf
···
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character-set-server = utf8
collation-server = utf8_general_ci

[client]
default-character-set = utf8
```

最新文章

  1. 106、抗锯齿方法paint.setAntiAlias(ture);paint.setFilterBitmap(true))
  2. Fiddler 过滤 css,图片等请求url 正则表达式
  3. BZOJ 4597 随机序列
  4. PL/SQL-Thread creation error:存储空间不足,无法处理此命令
  5. [CSS]position定位
  6. DataSet排序
  7. 加密解密技术—Web.config加密和解密
  8. Linux系统编程:客户端-服务器用FIFO进行通信
  9. Cygwin-添加到右键菜单脚本--一键安装、卸载
  10. 关于.net中的DataSet和DataTable
  11. Ubuntu14.04+Dell 7060安装无线/有线网络驱动
  12. windows下配置maven
  13. mysql 开启root外部链接权限
  14. Spring Security(十二):5. Java Configuration
  15. Fluent动网格【11】:弹簧光顺
  16. 批处理DOS基础命令
  17. Python 3种运行方式
  18. css中“~”和“>”是什么意思
  19. POJ 2390
  20. [ 原创 ] Java基础6--构造函数和抽象类的性质

热门文章

  1. [网络流 24 题] luoguP2763 试题库问题
  2. [BZOJ3449] [Usaco2014 Feb]Secret Code
  3. 小工具---将图片文件MultipartFile保存到指定目录
  4. 在Hadoop上用Python实现WordCount
  5. webpack——npm -i 与npm install -s与-d的区别
  6. 在已有 Windows10 系统的基础上,安装 Ubuntu17.10 系统(新版 BIOS)
  7. 一文理解java对象初始化顺序
  8. OptimalSolution(9)--其他问题(1)
  9. vue表单和组件使用
  10. Sping MVC不使用任何注解处理(jQuery)Ajax请求(基于XML配置)