MySQL57安装与设置
安裝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、檢查狀態(tài)、設置為開機自啟
[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';
創(chuàng)建數(shù)據(jù)庫(數(shù)據(jù)庫名為:test)
mysql> create database test;
使用test數(shù)據(jù)庫
mysql> use crashcourse;
執(zhí)行sql腳本(使用source命令)
mysql> source /root/MySQLCrashCourse/create.sql;
mysql> source /root/MySQLCrashCourse/populate.sql;
查看可用數(shù)據(jù)庫的列表
mysql> show databases;
查看當前數(shù)據(jù)庫內(nèi)可用表的列表
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;
創(chuàng)建用戶賬號
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
```
轉載于:https://www.cnblogs.com/colman/p/11045699.html
總結
以上是生活随笔為你收集整理的MySQL57安装与设置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python+selenium浏览器常用
- 下一篇: 《学习之道》第十三章自己也要总结