centos 7二進(jìn)制安裝mysql5.7.26

一相味、環(huán)境準(zhǔn)備

1.1 關(guān)閉防火墻

#停止防火墻

systemctl stop firewalld.service

#禁止firewall開機(jī)啟動(dòng)

systemctl disable firewalld.service

#查看默認(rèn)防火墻狀態(tài)

firewall-cmd--state

1.2 安裝必備軟件

#更新軟件包

yum -y update

#安裝上傳下載lszrz

yum -y install lszrz

#安裝wget

yum -y install wget




二、安裝mysql過(guò)程

1.1 檢查是否安裝MySQL,如果安裝 卸載之


rpm -qa |grep mysql

yum? remove mysql*

1.2 檢查是否安裝MariaDB,如果安裝 卸載之(重要)

rpm -qa |grep mariadb

yum remove mariadb*

1.3 wget下載mysql5.7.26

#建立目錄用來(lái)放需要安裝的軟件(自己習(xí)慣來(lái)建目錄)

mkdir -p /app

#下載????

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

有點(diǎn)慢睦柴,可以到官網(wǎng)下載,在rz? -y上傳

1.4? 解壓并且改名為mysql

[root@mysql app]# ls

mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

[root@mysql app]# tar -xzvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

[root@mysql app]# mv mysql-5.7.26-linux-glibc2.12-x86_64/ mysql

1.5 修改環(huán)境變量

[root@mysql app]# vi /etc/profile

#在最后添加即可

exportPATH=/app/mysql/bin:$PATH

#生效

[root@mysql app]# source /etc/profile

1.6? 建立mysql用戶和組

useradd mysql

1.7 創(chuàng)建相關(guān)目錄并修改權(quán)限

[root@mysql app]# mkdir /data/mysql -p

[root@mysql app]# chown -R mysql.mysql /app/*

[root@mysql app]# chown -R mysql.mysql /data/*


1.8 初始化數(shù)據(jù)庫(kù)

[root@mysql mysql]# rm -rf /data/mysql/*

[root@mysql mysql]# mysqld --initialize-insecure --user=mysql --basedir=/app/mysql --datadir=/data/mysql

2019-08-20T03:29:54.126839Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2019-08-20T03:29:55.345568Z 0 [Warning] InnoDB: New log files created, LSN=45790

2019-08-20T03:29:55.536508Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2019-08-20T03:29:55.617830Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: c77fff90-c2fa-11e9-bb4a-080027383c74.

2019-08-20T03:29:55.624489Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2019-08-20T03:29:55.627494Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

1.9 修改添加配置文件my.cnf

[root@mysql tmp]# vi /etc/my.cnf

[client]

port = 3306

socket = /tmp/mysql.sock

[mysqld]

user=mysql

basedir=/app/mysql

datadir=/data/mysql

server_id=1

port=3306

socket=/tmp/mysql.sock

tmpdir? = /tmp

skip_name_resolve = 1

character-set-server = utf8mb4

collation-server = utf8mb4_general_ci

init_connect='SET NAMES utf8mb4'

lower_case_table_names = 1

max_connections = 400

max_connect_errors = 1000

interactive_timeout = 1800

wait_timeout = 1800

tmp_table_size = 134217728

max_heap_table_size = 134217728

log_error = /tmp/error.log

[mysql]

socket=/tmp/mysql.sock

prompt=3306 [\\d]>

1.10 使用systemd管理mysql

[root@mysql mysql]# vi /etc/systemd/system/mysqld.service

[Unit]

Description=MySQL Server

Documentation=man:mysqld(8)

Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

ExecStart=/app/mysql/bin/mysqld --defaults-file=/etc/my.cnf

LimitNOFILE = 5000

systemctl start/stop/restart/status mysqld

1.11 簡(jiǎn)單使用

#直接mysql命令進(jìn)入(此時(shí)密碼為空)

[root@mysql mysql]# mysql

Welcome to the MySQL monitor.? Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

#用戶信息? descmysql.user;

5.6版本:

select user,password,hostfrommysql.user;

5.7中用戶基本信息

3306 [(none)]>select user,authentication_string,host from mysql.user;

+---------------+-------------------------------------------+-----------+

| user? ? ? ? ? | authentication_string? ? ? ? ? ? ? ? ? ? | host? ? ? |

+---------------+-------------------------------------------+-----------+

| root? ? ? ? ? |? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | localhost |

| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |

| mysql.sys? ? | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |

+---------------+-------------------------------------------+-----------+

3 rows in set (0.00 sec)

#修改密碼

[root@mysql mysql]# mysqladmin -uroot -p password '*******';

Enter password:

mysqladmin: [Warning] Using a password on the command line interface can be insecure.

Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety

#查看連接線程情況

3306 [(none)]>show processlist;

+----+------+-----------+------+---------+------+----------+------------------+

| Id | User | Host? ? ? | db? | Command | Time | State? ? | Info? ? ? ? ? ? |

+----+------+-----------+------+---------+------+----------+------------------+

| 10 | root | localhost | NULL | Query? |? ? 0 | starting | show processlist |

+----+------+-----------+------+---------+------+----------+------------------+

1 row in set (0.00 sec)

1.12 外部第三方管理軟件連接(SQLyog)

數(shù)據(jù)庫(kù)IP地址為 192.168.0.11 不能連接


#查看授權(quán)

3306 [(none)]>show grants for root@'192.168.0.%';

ERROR 1141 (42000): There is no such grant defined for user 'root' on host '192.168.0.%'

#主要是由于用戶和權(quán)限管理的問題翘盖,后面配置

1.13 用戶

#用戶的增刪改查

3306 [(none)]>create user victor@'192.168.0.%' identified by 'victor';

Query OK, 0 rows affected (0.00 sec)

3306 [(none)]>desc mysql.user;

3306 [(none)]>select user ,host ,authentication_string from mysql.user;

------

3306 [(none)]>alter user victor@'192.168.0.%' identified by '123456';

Query OK, 0 rows affected (0.00 sec)

3306 [(none)]>drop user victor@'192.168.0.%';

Query OK, 0 rows affected (0.00 sec)

1.14 權(quán)限管理

#先創(chuàng)建test 用戶

3306 [(none)]>create user test@'192.168.0.%' identified by 'test';

Query OK, 0 rows affected (0.00 sec)

#分配test用戶權(quán)限

3306 [(none)]>grant all on *.* to 'test'@'192.168.0.%';

Query OK, 0 rows affected (0.00 sec)

#用SQLyog連接?

ip地址:

192.168.0.11

用戶名

test

密碼

test


#權(quán)限介紹

ALL:SELECT,INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACEALL : 以上所有權(quán)限澎嚣,一般是普通管理員擁有的withgrant option:超級(jí)管理員才具備的,給別的用戶授權(quán)的功能

#查看授權(quán)

3306 [(none)]>show grants for test@'192.168.0.%';

+-----------------------------------------------------+

| Grants for test@192.168.0.%? ? ? ? ? ? ? ? ? ? ? ? |

+-----------------------------------------------------+

| GRANT ALL PRIVILEGES ON *.* TO 'test'@'192.168.0.%' |

+-----------------------------------------------------+

1 row in set (0.00 sec)

#回收授權(quán)

revoke delete on *.*? from test@'192.168.0.%'榆鼠;

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市亥鸠,隨后出現(xiàn)的幾起案子妆够,更是在濱河造成了極大的恐慌识啦,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,692評(píng)論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件神妹,死亡現(xiàn)場(chǎng)離奇詭異颓哮,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)鸵荠,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,482評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門冕茅,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人蛹找,你說(shuō)我怎么就攤上這事姨伤。” “怎么了熄赡?”我有些...
    開封第一講書人閱讀 162,995評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵姜挺,是天一觀的道長(zhǎng)齿税。 經(jīng)常有香客問我彼硫,道長(zhǎng),這世上最難降的妖魔是什么凌箕? 我笑而不...
    開封第一講書人閱讀 58,223評(píng)論 1 292
  • 正文 為了忘掉前任拧篮,我火速辦了婚禮,結(jié)果婚禮上牵舱,老公的妹妹穿的比我還像新娘串绩。我一直安慰自己,他們只是感情好芜壁,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,245評(píng)論 6 388
  • 文/花漫 我一把揭開白布礁凡。 她就那樣靜靜地躺著,像睡著了一般慧妄。 火紅的嫁衣襯著肌膚如雪顷牌。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,208評(píng)論 1 299
  • 那天塞淹,我揣著相機(jī)與錄音窟蓝,去河邊找鬼。 笑死饱普,一個(gè)胖子當(dāng)著我的面吹牛运挫,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播套耕,決...
    沈念sama閱讀 40,091評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼谁帕,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了冯袍?” 一聲冷哼從身側(cè)響起匈挖,我...
    開封第一講書人閱讀 38,929評(píng)論 0 274
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后关划,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體小染,經(jīng)...
    沈念sama閱讀 45,346評(píng)論 1 311
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,570評(píng)論 2 333
  • 正文 我和宋清朗相戀三年贮折,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了裤翩。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,739評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡调榄,死狀恐怖踊赠,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情每庆,我是刑警寧澤筐带,帶...
    沈念sama閱讀 35,437評(píng)論 5 344
  • 正文 年R本政府宣布,位于F島的核電站缤灵,受9級(jí)特大地震影響伦籍,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜腮出,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,037評(píng)論 3 326
  • 文/蒙蒙 一帖鸦、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧胚嘲,春花似錦作儿、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,677評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至妓雾,卻和暖如春娶吞,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背君珠。 一陣腳步聲響...
    開封第一講書人閱讀 32,833評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工寝志, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人策添。 一個(gè)月前我還...
    沈念sama閱讀 47,760評(píng)論 2 369
  • 正文 我出身青樓材部,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親唯竹。 傳聞我的和親對(duì)象是個(gè)殘疾皇子乐导,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,647評(píng)論 2 354