mysql安装流程

[root@n5 ~]# rpm -q mariadb-server mariadb    #如果之前安装过mariadb,需要卸载

[root@n5 ~]# ls    #把安装包上传到root目录下
anaconda-ks.cfg  mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

[root@n5 ~]# useradd -r mysql    #创建一个系统用户mysql

[root@n5 ~]# id mysql
uid=997(mysql) gid=995(mysql) groups=995(mysql)

[root@n5 ~]# tar xf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local    #展开安装包

[root@n5 ~]# cd /usr/local/
[root@n5 local]# ln -sn mysql-5.7.18-linux-glibc2.5-x86_64/ mysql    #制作链接文件
lrwxrwxrwx  1 root root  35 Apr 12 23:20 mysql -> mysql-5.7.18-linux-glibc2.5-x86_64/
[root@n5 local]# cd mysql
[root@n5 mysql]# chown -R root.mysql ./\*    #修改mysql所有文件属组为mysql
[root@n5 mysql]# ll
total 36
drwxr-xr-x  2 root mysql  4096 Apr 12 23:16 bin
-rw-r--r--  1 root mysql 17987 Mar 18  2017 COPYING
drwxr-xr-x  2 root mysql    55 Apr 12 23:16 docs
drwxr-xr-x  3 root mysql  4096 Apr 12 23:16 include
drwxr-xr-x  5 root mysql   229 Apr 12 23:16 lib
drwxr-xr-x  4 root mysql    30 Apr 12 23:16 man
-rw-r--r--  1 root mysql  2478 Mar 18  2017 README
drwxr-xr-x 28 root mysql  4096 Apr 12 23:16 share
drwxr-xr-x  2 root mysql    90 Apr 12 23:16 support-files
[root@n5 mysql]# mkdir -pv /data/mysql    #创建mysql数据目录
mkdir: created directory ‘/data’
mkdir: created directory ‘/data/mysql’
[root@n5 mysql]# chown -R mysql.mysql /data/mysql/    #mysql进程要进行写操作,修改权限
[root@n5 mysql]# ll /data
total 0
drwxr-xr-x 2 mysql mysql 6 Apr 12 23:28 mysql
[root@n5 mysql]# vim /etc/profile.d/mysql.sh    #编写修改环境变量脚本
export PATH=/usr/local/mysql/bin:$PATH
[root@n5 mysql]# . /etc/profile.d/mysql.sh    #读取环境变量

[root@n5 mysql]# mkdir etc
[root@n5 mysql]# mkdir logs
[root@n5 mysql]# chown -R mysql.mysql logs/    #更改日志目录权限
[root@n5 mysql]# mysqld --initialize-insecure --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql
2018-04-13T05:28:25.149583Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-04-13T05:28:25.948412Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-04-13T05:28:26.058553Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-04-13T05:28:26.121981Z 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: 7da0526b-3edb-11e8-a71c-000c2977a305.
2018-04-13T05:28:26.124459Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-04-13T05:28:26.127938Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@n5 mysql]# cp /etc/my.cnf etc/
[root@n5 mysql]# vim etc/my.cnf    #修改mysql配置文件
[mysqld]
datadir=/data/mysql
socket=/tmp/mysql.sock
symbolic-links=0
[mysqld_safe]
log-error=/usr/local/mysql/logs/error.log
pid-file=/var/run/mysql/mysql.pid
!includedir /usr/local/mysql/etc/my.cnf.d

[root@n5 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@n5 mysql]# ll /etc/init.d/mysqld    #确保有执行权限
-rwxr-xr-x 1 root root 10576 Apr 13 01:39 /etc/init.d/mysqld
[root@n5 mysql]# chkconfig --add mysqld
[root@n5 mysql]# mkdir etc/my.cnf.d
[root@n5 mysql]# touch logs/error.log    #新建错误日志文件
[root@n5 mysql]# chown -R mysql.mysql logs/error.log    #修改错误日志文件属主属组
[root@n5 mysql]# service mysql start    #开启mysql服务
Redirecting to /bin/systemctl start mysql.service
[root@n5 mysql]# mysql    #运行mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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.
mysql> 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 200,302评论 5 470
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,232评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 147,337评论 0 332
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,977评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,920评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,194评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,638评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,319评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,455评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,379评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,426评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,106评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,696评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,786评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,996评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,467评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,043评论 2 341

推荐阅读更多精彩内容