Mysql 5.3.6 安装

1.参考网址:

 https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

1.1 添加yum源

[root@master ~]# vi /etc/yum.repos.d/mysql-community.repo  #添加一下内容
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=0   #取消校验
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql



1.2 安装

[root@master ~]# yum install mysql-community-server

1.3 启动

 

systemctl start mysqld.service
这里会报错:

[root@master ~]# systemctl start mysqld.service
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@master ~]# journalctl -xe
-- 
-- Unit NetworkManager-dispatcher.service has finished starting up.
-- 
-- The start-up result is done.
Sep 14 16:53:57 master nm-dispatcher[11775]: Dispatching action 'dhcp4-change' for ens37
Sep 14 16:58:00 master polkitd[841]: Registered Authentication Agent for unix-process:11810:3401666 (system bus name :1.89 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, loca
Sep 14 16:58:00 master systemd[1]: Starting SYSV: MySQL database server....
-- Subject: Unit mysqld.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysqld.service has begun starting up.
Sep 14 16:58:00 master mysqld[11816]: Logging to '/var/log/mysql/mysql.log'.
Sep 14 16:58:03 master mysqld[11816]: MySQL Daemon failed to start.
Sep 14 16:58:03 master mysqld[11816]: Starting mysqld:  [FAILED]
Sep 14 16:58:03 master systemd[1]: mysqld.service: control process exited, code=exited status=1
Sep 14 16:58:04 master polkitd[841]: Unregistered Authentication Agent for unix-process:11810:3401666 (system bus name :1.89, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Sep 14 16:58:03 master systemd[1]: Failed to start SYSV: MySQL database server..
-- Subject: Unit mysqld.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysqld.service has failed.
-- 
-- The result is failed.
Sep 14 16:58:03 master systemd[1]: Unit mysqld.service entered failed state.
Sep 14 16:58:03 master systemd[1]: mysqld.service failed.
Sep 14 17:01:01 master systemd[1]: Started Session 25 of user root.
-- Subject: Unit session-25.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-25.scope has finished starting up.
-- 
-- The start-up result is done.
Sep 14 17:01:01 master systemd[1]: Starting Session 25 of user root.
-- Subject: Unit session-25.scope has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-25.scope has begun starting up.
Sep 14 17:01:01 master CROND[12105]: (root) CMD (run-parts /etc/cron.hourly)
Sep 14 17:01:02 master run-parts(/etc/cron.hourly)[12108]: starting 0anacron
Sep 14 17:01:02 master run-parts(/etc/cron.hourly)[12114]: finished 0anacron
Sep 14 17:01:02 master run-parts(/etc/cron.hourly)[12116]: starting 0yum-hourly.cron
Sep 14 17:01:02 master run-parts(/etc/cron.hourly)[12120]: finished 0yum-hourly.cron
Sep 14 17:03:22 master polkitd[841]: Registered Authentication Agent for unix-process:12127:3433822 (system bus name :1.92 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, loca
Sep 14 17:03:22 master systemd[1]: Starting SYSV: MySQL database server....
-- Subject: Unit mysqld.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysqld.service has begun starting up.
Sep 14 17:03:22 master mysqld[12133]: Logging to '/var/log/mysql/mysql.log'.
Sep 14 17:03:25 master mysqld[12133]: MySQL Daemon failed to start.
Sep 14 17:03:25 master mysqld[12133]: Starting mysqld:  [FAILED]
Sep 14 17:03:25 master systemd[1]: mysqld.service: control process exited, code=exited status=1
Sep 14 17:03:25 master systemd[1]: Failed to start SYSV: MySQL database server..
-- Subject: Unit mysqld.service has failed
上面只能看到mysql启动失败,并没有得到什么具体的信息,然后去查看/var/log/mysql,发现并没有东西。

里面什么都没有。很奇怪!!!
但是这里有问题,mysql 启动失败不会打印日志???
看了配置文件/etc/my.cnf 没啥问题.日志位置没毛病啊. 
后来才发现,mysql 安装读取的配置文件在/etc/my.conf ,这个文件的权限是root:root
后面试改权限:


[root@master etc]# chmod 777 /etc/my.cnf   #因为我是root 用户启动的,直接给777 ,进程是mysql用户的,所以其他组给7是必须的。
[root@master etc]#  systemctl start mysqld.service #可以启动了
[root@master etc]# systemctl status mysqld.service
● mysqld.service - SYSV: MySQL database server.
   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
   Active: active (running) since Thu 2017-09-14 17:07:08 EDT; 12s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 12452 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)
 Main PID: 12607 (mysqld)
   CGroup: /system.slice/mysqld.service
           ├─12478 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
           └─12607 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=master.err --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock

Sep 14 17:07:07 master mysqld[12452]: Warning: World-writable config file '/etc/my.cnf' is ignored
Sep 14 17:07:07 master mysqld[12452]: Warning: World-writable config file '/etc/my.cnf' is ignored
Sep 14 17:07:07 master mysqld[12452]: Warning: World-writable config file '/etc/my.cnf' is ignored
Sep 14 17:07:07 master mysqld[12452]: Warning: World-writable config file '/etc/my.cnf' is ignored
Sep 14 17:07:07 master mysqld[12452]: Warning: World-writable config file '/etc/my.cnf' is ignored
Sep 14 17:07:07 master mysqld[12452]: Warning: World-writable config file '/etc/my.cnf' is ignored
Sep 14 17:07:07 master mysqld[12452]: Logging to '/var/lib/mysql/master.err'.
Sep 14 17:07:08 master mysqld[12452]: Starting mysqld:  [  OK  ]
Sep 14 17:07:08 master systemd[1]: mysqld.service: Supervising process 12607 which is not our child. We'll most likely not notice when it exits.
Sep 14 17:07:08 master systemd[1]: Started SYSV: MySQL database server..

1.4.登录

[root@master etc]# mysql -uroot -p  #默认密码 123456
Warning: World-writable config file '/etc/my.cnf' is ignored   #前面的权限给大了,mysql 会判断/etc/my.cnf 权限是不是644 ,不是就会报警告!!可以chmod 644 /etc/my.conf
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.37 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.02 sec)

mysql> 


总结:安装时注意配置文件的权限问题,这里采用的默认安装路径,并没有涉及到权限问题设置。

初始密码:

[root@master ~]# cat .mysql_secret  #mysql安装完,生成随机的密码文件
# The random password set for the root user at Thu May  4 22:47:28 2017 (local time): EuG4BJ_gWrZ5KpBZ

也有可能在在mysql 的错误日志里面:

grep 'temporary password' /var/log/mysqld.log








  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值