mysql57 MySQL57安裝與設定

2021-10-25 14:16:38 字數 2035 閱讀 3576

安裝mysql

新增mysql源

安裝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

mysql5 7安裝部落格園 mysql5 7安裝

root localhost cd usr softwares root localhost softwares rz 2 解壓檔案 解壓檔案 root localhost softwares tar xzvf mysql 5.7.23 linux glibc2.12 x86 64.tar.gz 將...

mysql5 7學習 mysql 5 7 學習

mysql uroot proot mysql5.7 mysql.user表沒有password欄位改 authentication string 一.建立使用者 命令 create user username host identified by password 例子 create user d...

mysql5 7如何開啟 mysql57怎麼開啟

開啟mysql57的方法 首先開啟winodws執行視窗 然後在開啟編輯框中輸入cmd命令 最後在終端介面中輸入 mysql hlocalhost uroot p123 即可顯示開啟mysql資料庫。windows下用命令列啟動mysql5.7 win菜單鍵即是在鍵盤左下角 ctrl控制 鍵與 al...