日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

MySQL57安装与设置

發(fā)布時間:2023/11/27 生活经验 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySQL57安装与设置 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

安裝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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。