CentOS7安装MySQL

--下载mysql

http://mirrors.sohu.com/mysql/MySQL-5.6/

http://mirrors.sohu.com/mysql/MySQL-5.6/MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar





一。准备工作

--下载后文件

MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar





--新建目录

mkdir /home/www/tar

mkdir /home/www/rpm





--上传文件至rpm包下解压

tar -xvf MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar

...

MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar

MySQL-client-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-devel-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-embedded-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-server-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-shared-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-shared-compat-5.6.24-1.linux_glibc2.5.x86_64.rpm

MySQL-test-5.6.24-1.linux_glibc2.5.x86_64.rpm



--把tar文件移至/home/www/tar

mv MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar /home/www/tar





二、開始安装

--開始安装(当中。v表示显示具体安装信息,h表示显示用#表示安装进度)

rpm -ivh MySQL-*





--看到例如以下信息已成功安装

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !

You will find that password in '/root/.mysql_secret'.

...

...

New default config file was created as /usr/my.cnf and

will be used by default by the server when you start it.

You may edit this file to change server settings





备注:最新版的MySQL将随机生成一个root用户的password,放在/root/.mysql_secret 文件里





--查看port(默认3306)

[root@localhost init.d]# netstat -nat

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address           Foreign Address         State      

tcp        0      0 0.0.0.0:3690            0.0.0.0:*               LISTEN     

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     

tcp        0      0 192.168.1.110:22        192.168.1.119:50608     ESTABLISHED

tcp6       0      0 :::3306                 :::*                    LISTEN     

tcp6       0      0 :::22                   :::*                    LISTEN





三、安装位置

用RPM进行安装的时候,MySQL下的子文件夹被分散开,分别放在了下面几个文件夹下:

/etc/logrotate.d/mysql

/etc/rc.d/init.d/mysql // mysql启动配置脚本,当中仅仅有一个叫mysql的可运行文件 与mysql有关

/var/lib/mysql // Mysql中的数据库存放文件夹

/var/lock/subsys/mysql

/usr/lib/mysql                  //  该目录下是mysql链接库

/usr/include/mysql //  mysql 头文件

/usr/share/mysql //  mysql 安装文件夹

/usr/bin // 当中有mysql的多个可运行程序,如mysql、mysql_config_editor、mysqlcheck、mysqladmin等





四、mysql停止与重新启动

/etc/rc.d/init.d/mysql restart

/etc/rc.d/init.d/mysql stop

/etc/rc.d/init.d/mysql start





五、错误排查

[root@localhost rpm]# mysql -uroot

--出现故障

(1)报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

--停止服务

/etc/rc.d/init.d/mysql stop

--安全模式进入mysql

[root@localhost rpm]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

[root@localhost rpm]# mysql -u root mysql

--更改username

mysql> UPDATE user SET Password=PASSWORD('root') where User='root';

mysql> FLUSH PRIVILEGES;

mysql> quit

[root@localhost rpm]# mysql -uroot -p

mysql> show databases;

(2)报错:ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

--又一次设置rootpassword

mysql> SET PASSWORD = PASSWORD('root');

Query OK, 0 rows affected (0.00 sec)

mysql> show databases;

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

| test               |

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

4 rows in set (0.00 sec)





(3)navicat报错:Host '192.168.1.*' is not allowed to connect to this MySQL server

原因:mysql下user表中不同意外部链接

--暂时把port增加防火墙

firewall-cmd --permanent --zone=public --add-port=3306/tcp

systemctl restart firewalld.service

--更改host

[root@localhost rpm]# mysql -uroot -p

mysql> use mysql

mysql> select host, user from user;

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

| host                  | user |

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

| 127.0.0.1             | root |

| ::1                   | root |

| localhost             | root |

| localhost.localdomain | root |

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

4 rows in set (0.00 sec)

--更改localhost为%

mysql> update user set host = '%' where host='localhost';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0



mysql> select host, user from user;

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

| host                  | user |

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

| %                     | root |

| 127.0.0.1             | root |

| ::1                   | root |

| localhost.localdomain | root |

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

4 rows in set (0.00 sec)

--重新启动mysql服务

/etc/rc.d/init.d/mysql restart



至此mysql已能够正常使用!





六、开机启动

使用命令:sbin/chkconfig --list,查看启动项

使用命令:sbin/chkconfig --add mysql,将mysql加入到开机启动项中:

使用命令:sbin/chkconfig --del mysql,将mysql从启动项删除:

版权声明:本文博客原创文章,博客,未经同意,不得转载。

CentOS7下一个mysql安装的更多相关文章

  1. CentOS7 下的mysql安装与配置

    之前虽然也安装过多次mysql,但每次都会遇到各种小问题,这次记录下来,以备后查. 首先是下载与安装 # wget http://dev.mysql.com/get/mysql-community-r ...

  2. centos7下使用yum安装mysql

    CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 wget http://repo.mysql.com/m ...

  3. Centos7 下的SVN安装与配置

    Centos7 下的SVN安装与配置 1.关闭防火墙 临时关闭防火墙 systemctl stop firewalld 永久防火墙开机自关闭 systemctl disable firewalld 临 ...

  4. CentOS7 下源码安装 python3

    CentOS 7 下源码安装 python3   在CentOS7下,默认安装的是python2.7:为满足项目要求,安装python3 的方法如下:   1. 首先安装python3.6可能使用的依 ...

  5. CentOS7下NFS服务安装及配置固定端口

    CentOS7下NFS服务安装及配置 系统环境:CentOS Linux release 7.4.1708 (Core) 3.10.0-693.el7.x86_64 软件版本:nfs-utils-1. ...

  6. [转]Centos7下caffe的安装

    Centos7下caffe的安装 原文地址:http://blog.csdn.net/s2392735818/article/details/49796017   版权声明:本文为博主原创文章,未经博 ...

  7. Memcahce(MC)系列(两)Linux下一个Memcache安装

    Linux下一个memcache安装 memcache是高性能.分布式的内存对象缓存系统,用于在动态应用中降低数据库负载.提升訪问速度.眼下用memcache解决互联网上的大用户读取是很流行的一种使用 ...

  8. Linux 下一个 Mysql error 2002 错误解决

    Linux 下一个 Mysql error 2002 错误解决     首先查看 /etc/rc.d/init.d/mysqld status 查看mysql它已开始.     假设启动的的话,先将数 ...

  9. centos7下搜狗输入法的安装教程

    相信用过centos自带的输入法的朋友都会感叹这也实在是太难用了吧,使用拼音打出来的词总是不能在前几个匹配到,即使是一些常用词也是如此,简直无法忍受跟个zz似的.吐槽完了,这里给出centos7下搜狗 ...

随机推荐

  1. python - ImportError: No module named http.cookies error when installing cherrypy 3.2 - Stack Overflow

    python - ImportError: No module named http.cookies error when installing cherrypy 3.2 - Stack Overfl ...

  2. 第一章. ActionScript 语言基础

    第一章. ActionScript 语言基础 1.0. ActionScript 3.0 Cookbook 概述 1.1. 新建一个 ActionScript project 1.2. 自己定义应用程 ...

  3. TopCoder SRM 625 Incrementing Sequence 题解

    本题就是给出一个数k和一个数组,包含N个元素,通过每次添加�数组中的一个数的操作,最后须要得到1 - N的一个序列,不用排序. 能够从暴力法入手,然后优化. 这里利用hash表进行优化,终于得到时间效 ...

  4. 内存级别/栅栏 ( Memory Barriers / Fences ) – 翻译

    翻译自:Martin Thompson – Memory Barriers/Fences 在这篇文章里,我将讨论并发编程里最基础的技术–以内存关卡或栅栏著称.那让进程内的内存状态对其它进程可见. CP ...

  5. 【IOS实例小计】今日开贴,记录我的ios学习生涯,留下点滴,留下快乐,成荫后人。

    今天开贴来记录自己的ios学习过程,本人目前小白一个,由于对ios感兴趣,所以开始学习,原职java程序,呵呵,勿喷. 本次的[ios实例小计]主要参考一文http://blog.sina.com.c ...

  6. HDU 4869 Turn the pokers(推理)

    HDU 4869 Turn the pokers 题目链接 题意:给定n个翻转扑克方式,每次方式相应能够选择当中xi张进行翻转.一共同拥有m张牌.问最后翻转之后的情况数 思路:对于每一些翻转,假设能确 ...

  7. NYOJ 12 喷水装置(二)

    pid=12">喷水装置(二) 时间限制:3000 ms  |  内存限制:65535 KB 难度:4 描写叙述 有一块草坪,横向长w,纵向长为h,在它的橫向中心线上不同位置处装有n( ...

  8. ServicePrvider实现揭秘

    ServicePrvider实现揭秘 到目前为止,我们定义的ServiceProvider已经实现了基本的服务提供和回收功能,但是依然漏掉了一些必需的细节特性.这些特性包括如何针对IServicePr ...

  9. 利用Nginx构建负载均衡server

    大家都知道.一个域名相应一个IP地址,而一个WebSite则相应一个IP地址上相应port服务的应用程序(或位置).而大型站点的并发訪问量很大,这些站点是怎样在一台Webserver上实现负载均衡的呢 ...

  10. Linux查看用户数、登录用户

    如果是系统中全部只要默认shell是bash的就包括那么二楼正解,就是cat /etc/passwd|grep bash|wc -l如果是正在登陆系统的账户中使用bash shell的,那么ps -e ...