去mysql官网下载yum配置文件,
按操作系统版本下载:
https://dev.mysql.com/downloads/repo/yum/
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# ll mysql*
-rw-r--r-- 1 root root 25680 Dec 20 11:31
mysql57-community-release-el7-11.noarch.rpm
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# yum localinstall
mysql57-community-release-el7-11.noarch.rpm
Loaded plugins: fastestmirror, langpacks
Examining mysql57-community-release-el7-11.noarch.rpm:
mysql57-community-release-el7-11.noarch
Marking mysql57-community-release-el7-11.noarch.rpm to be
installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el7-11 will
be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================================================
Package
Arch
Version
Repository
Size
========================================================================================================================================================================================================
Installing:
mysql57-community-release
noarch
el7-11
/mysql57-community-release-el7-11.noarch
31 k
Transaction Summary
========================================================================================================================================================================================================
Install 1 Package
Total size: 31 k
Installed size: 31 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s), 'yum check' output
follows:
ipa-client-common-4.4.0-14.el7.centos.7.noarch has installed
conflicts freeipa-client-common:
ipa-client-common-4.4.0-14.el7.centos.7.noarch
ipa-common-4.4.0-14.el7.centos.7.noarch has installed
conflicts freeipa-common:
ipa-common-4.4.0-14.el7.centos.7.noarch
Installing :
mysql57-community-release-el7-11.noarch
1/1
Verifying :
mysql57-community-release-el7-11.noarch
1/1
Installed:
mysql57-community-release.noarch 0:el7-11
Complete!
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# yum list mysql
Loaded plugins: fastestmirror, langpacks
http://repo.mysql.com/yum/mysql-connectors-community/el/7/x86_64/repodata/repomd.xml:
[Errno 12] Timeout on
http://repo.mysql.com/yum/mysql-connectors-community/el/7/x86_64/repodata/repomd.xml:
(28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
http://repo.mysql.com/yum/mysql-connectors-community/el/7/x86_64/repodata/repomd.xml:
[Errno 12] Timeout on
http://repo.mysql.com/yum/mysql-connectors-community/el/7/x86_64/repodata/repomd.xml:
(28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
这里是因为网络不通唱。
[root@VM_64_101_centos ~]# yum install mysql
Loaded plugins: fastestmirror, langpacks
epel
| 4.7 kB
00:00:00
extras
| 3.4 kB
00:00:00
http://repo.mysql.com/yum/mysql-connectors-community/el/7/x86_64/repodata/repomd.xml:
[Errno 12] Timeout on
http://repo.mysql.com/yum/mysql-connectors-community/el/7/x86_64/repodata/repomd.xml:
(28, 'Connection timed out after 30000 milliseconds')
Trying other mirror.
http://repo.mysql.com/yum/mysql-connectors-community/el/7/x86_64/repodata/repomd.xml:
[Errno 12] Timeout on
http://repo.mysql.com/yum/mysql-connectors-community/el/7/x86_64/repodata/repomd.xml:
(28, 'Connection timed out after 30000 milliseconds')
Trying other mirror.
=======================================
CentOS 7下yum成功安装 MySQL 5.7
第一部分:CentOS 7安装MySQL 5.7
1.下载YUM库
shell > wget
http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
2.安装YUM库
shell > yum localinstall -y
mysql57-community-release-el7-7.noarch.rpm
3.安装数据库
shell > yum install -y mysql-community-server
4.启动MySQL服务
shell > systemctl start mysqld.service
5.默认空密码
shell > mysql -uroot -p
6.重置root密码后重启mysql服务
shell > update mysql.user set
authentication_string=password("yourpassword") where user="root"
and Host="localhost";
shell > flush privileges;
shell > quit;
shell > systemctl restart mysqld;
如果手贱或者不知道啥原因出现如下问题:
ERROR 1045 (28000): Access denied for user 'root'@'localhost'
(using password: NO)
请修改my.cnf,添加skip-grant-tables和skip-networking:
shell > vi /etc/my.cnf
[mysqld]
skip-grant-tables
skip-networking
重启mysql,然后重复以上修改密码步骤即可,记得修改完后,去掉my.cnf添加的两行。
第二部分:配置
1、添加远程登录用户(登入Mysql)
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密码'
WITH GRANT OPTION;
注:'%'代表任意地址,也可以指定IP
2、检查用户表,刷新内存权限
select host, user from user;
FLUSH PRIVILEGES;
CentOS 7下yum成功安装 MySQL 5.7
3、设置防火墙(CentOS7 不推荐)
vi /etc/sysconfig/iptables
在-A RH-Firewall-1-INPUT -j REJECT –reject-with
icmp-host-prohibited之前,添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j
ACCEPT
重启防火墙
service iptables restart
注:centos7使用的是firewall防火墙
systemctl stop firewalld.service #停止
systemctl disable firewalld.service #禁用
4、设置字符编码集和区分大小写
4.1修改mysql配置文件(设置字符编码集)
默认位置:/etc/my.cnf
进入etc文件夹>>vim my.cnf
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
CentOS 7下yum成功安装 MySQL 5.7
* systemctl restart mysql.service #重启MySQL
* 查看当前mysql运行状态
mysql>status
参数说明:
haracter_set_client:客户端请求数据的字符集。
character_set_connection:从客户端接收到数据,然后传输的字符集。
character_set_database:默认数据库的字符集,无论默认数据库如何改变,都是这个字符集;如果没有默认数据库,使character_set_server指定的字符集,此参数无需设置。
character_set_filesystem:把操作系统上文件名转化成此字符集,即把character_set_client转换character_set_filesystem,默认binary即可。
character_set_results:结果集的字符集。
character_set_server:数据库服务器的默认字符集。
character_set_system:这个值总是utf8,不需要设置,存储系统元数据的字符集。
4.2修改mysql配置文件(设置区分大小写)
lower_case_table_names 参数详解:
0:区分大小写
1:不区分大小写
==============================================================
CentOS 7 卸载 玛丽亚
并yum成功安装 MySQL 5.7
首先CentOS7 已经不自带mysql,因为收费了你懂得,
所以内部集成了mariadb,而安装mysql的话会和mariadb的文件冲突,所以需要先卸载掉mariadb,以下为卸载mariadb,安装mysql的步骤。
#列出所有被安装的rpm package
rpm -qa | grep mariadb
#卸载
rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64
错误:依赖检测失败:
libmysqlclient.so.18()(64bit) 被 (已安裝)
postfix-2:2.10.1-6.el7.x86_64 需要
libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝)
postfix-2:2.10.1-6.el7.x86_64 需要
#强制卸载,因为没有--nodeps
rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -e mariadb-libs
error: Failed dependencies:
libmysqlclient.so.18()(64bit) is needed by (installed)
postfix-2:2.10.1-6.el7.x86_64
libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by
(installed) postfix-2:2.10.1-6.el7.x86_64
[root@VM_64_101_centos ~]# rpm -e
--nodeps mariadb-libs
[root@VM_64_101_centos ~]# rpm -qa |grep
mariadb
[root@VM_64_101_centos ~]#
#安装mysql依赖
yum install vim libaio net-tools
其他情况:
1、centos下yum暂时没有mysql-server直接安装包;
MariaDB是MySQL社区开发的分支,也是一个增强型的替代品;
2、安装MariaDB
yum -y install mariadb-server mariadb mariadb-devel
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
firewall-cmd --permanent --add-service mysql
systemctl restart firewalld.service
iptables -L -n|grep 3306
CentOS7的yum源中默认好像是没有mysql的。为了解决这个问题,我们要先下载mysql的repo源。
1. 下载mysql的repo源
$ wget
http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. 安装mysql-community-release-el7-5.noarch.rpm包
$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装这个包后,会获得两个mysql的yum
repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。
3. 安装mysql
$ sudo yum install mysql-server
根据步骤安装就可以了,不过安装完成后,没有密码,需要重置密码。
4. 重置密码
重置密码前,首先要登录
$ mysql -u root
登录时有可能报这样的错:ERROR 2002 (HY000): Can‘t connect to local MySQL
server through socket ‘/var/lib/mysql/mysql.sock‘
(2),原因是/var/lib/mysql的访问权限问题。下面的命令把/var/lib/mysql的拥有者改为当前用户:
$ sudo chown -R openscanner:openscanner /var/lib/mysql
然后,重启服务:
$ service mysqld restart
接下来登录重置密码:
$ mysql -u root
mysql > use mysql;
mysql > update user set password=password(‘123456‘) where
user=‘root‘;
mysql > exit;
5. 开放3306端口
$ sudo vim /etc/sysconfig/iptables
添加以下内容:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j
ACCEPT
保存后重启防火墙:
$ sudo service iptables restart
这样从其它客户机也可以连接上mysql服务了。
MYSQL启动后报:ERROR! The server quit without updating PID
file错误的问题解决
MYSQL日志:Can't find file: './mysql/plugin.frm' (errno: 13 -
Permission denied)
1、权限不够:chown -R mysql:mysql /home/mysql/data” “chmod -R 755
/home/mysql/data
2、centos7的selinux问题:打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器。
mysql rpm包的先后循序依赖关系
==============================================
正好按文件size 从小到大 安装顺序
-rw-r--r-- 1 root root 272K Dec 20 16:25
mysql-community-common-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 2.2M Dec 20 16:20
mysql-community-libs-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 3.7M Dec 20 16:04
mysql-community-devel-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 24M Dec 20 16:05
mysql-community-client-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 164M Dec 20 16:34
mysql-community-server-5.7.20-1.el7.x86_64.rpm
[root@VM_64_101_centos ~]# rpm -ivh
rpm: no packages given for install
[root@VM_64_101_centos ~]# rpm -ivh
rpm: no packages given for install
[root@VM_64_101_centos ~]# rpm -ivh
mysql-community-devel-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-devel-5.7.20-1.el7.x86_64.rpm: Header
V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libmysqlclient.so.20()(64bit) is needed by
mysql-community-devel-5.7.20-1.el7.x86_64
mysql-community-libs(x86-64) >= 5.7.9 is needed by
mysql-community-devel-5.7.20-1.el7.x86_64
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -ivh
mysql-community-server-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.20-1.el7.x86_64.rpm:
Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-client(x86-64) >= 5.7.9 is needed by
mysql-community-server-5.7.20-1.el7.x86_64
mysql-community-common(x86-64) = 5.7.20-1.el7 is needed by
mysql-community-server-5.7.20-1.el7.x86_64
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -ivh
mysql-community-client-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.20-1.el7.x86_64.rpm:
Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-libs(x86-64) >= 5.7.9 is needed by
mysql-community-client-5.7.20-1.el7.x86_64
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -ivh
mysql-community-libs-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.20-1.el7.x86_64.rpm: Header
V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-common(x86-64) >= 5.7.9 is needed by
mysql-community-libs-5.7.20-1.el7.x86_64
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
sample
====================================
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -qa |grep
mysql
mysql57-community-release-el7-11.noarch
[root@VM_64_101_centos ~]# rpm -e
mysql57-community-release-el7-11.noarch
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -qa |grep
mysql
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -ivh
mysql-community-common
error: open of mysql-community-common failed: No such file or
directory
[root@VM_64_101_centos ~]# rpm -ivh
mysql-community-common*
warning: mysql-community-common-5.7.20-1.el7.x86_64.rpm:
Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...
################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.20-1.e#################################
[100%]
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -qa |grep
mysql
mysql-community-common-5.7.20-1.el7.x86_64
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -ivh
mysql-community-devel-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-devel-5.7.20-1.el7.x86_64.rpm: Header
V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libmysqlclient.so.20()(64bit) is needed by
mysql-community-devel-5.7.20-1.el7.x86_64
mysql-community-libs(x86-64) >= 5.7.9 is needed by
mysql-community-devel-5.7.20-1.el7.x86_64
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -ivh
mysql-community-libs-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.20-1.el7.x86_64.rpm: Header
V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...
################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.20-1.el7#################################
[100%]
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -qa |grep
mysql
mysql-community-libs-5.7.20-1.el7.x86_64
mysql-community-common-5.7.20-1.el7.x86_64
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -ivh
mysql-community-devel-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-devel-5.7.20-1.el7.x86_64.rpm: Header
V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...
################################# [100%]
Updating / installing...
1:mysql-community-devel-5.7.20-1.el#################################
[100%]
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -ivh
mysql-community-client-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.20-1.el7.x86_64.rpm:
Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...
################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.20-1.e#################################
[100%]
[root@VM_64_101_centos ~]# which mysql
/usr/bin/mysql
[root@VM_64_101_centos ~]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (2)
[root@VM_64_101_centos ~]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (2)
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -qa |grep
mysql
mysql-community-devel-5.7.20-1.el7.x86_64
mysql-community-libs-5.7.20-1.el7.x86_64
mysql-community-common-5.7.20-1.el7.x86_64
mysql-community-client-5.7.20-1.el7.x86_64
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -ivh
mysql-community-server-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.20-1.el7.x86_64.rpm:
Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...
################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.20-1.e#################################
[100%]
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# rpm -qa |grep
mysql
mysql-community-devel-5.7.20-1.el7.x86_64
mysql-community-libs-5.7.20-1.el7.x86_64
mysql-community-common-5.7.20-1.el7.x86_64
mysql-community-server-5.7.20-1.el7.x86_64
mysql-community-client-5.7.20-1.el7.x86_64
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# grep 'temporary password'
/var/log/mysqld.log
2017-12-20T09:02:40.636290Z 1 [Note] A temporary password is
generated for root@localhost: Fci&(oMns6kz
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# grep 'temporary password'
/var/log/mysqld.log
2017-12-20T09:02:40.636290Z 1 [Note] A temporary password is
generated for root@localhost: Fci&(oMns6kz
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# mysql -uroot
-pFci&(oMns6kz
>
> ^C
[root@VM_64_101_centos ~]# mysql -uroot -pFci&(oMns6kz
> ^C
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# mysql -uroot
-pFci&(oMns6kz
>
>
> ^C
[root@VM_64_101_centos ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end
with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.20
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>
mysql> alter user root@localhost identified by
'Qwerrttyui123!';
Query OK, 0 rows affected (0.00 sec)
[root@VM_64_101_centos ~]# systemctl list-unit-files|grep
sql
mysqld.service
enabled
mysqld@.service
disabled
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]#
[root@VM_64_101_centos ~]# systemctl status
mysqld.service
* mysqld.service - MySQL Server
Loaded: loaded
(/usr/lib/systemd/system/mysqld.service; enabled; vendor preset:
disabled)
Active: inactive
(dead)
Docs:
man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
[root@VM_64_101_centos ~]# systemctl start
mysqld.service
[root@VM_64_101_centos ~]# systemctl status
mysqld.service
* mysqld.service - MySQL Server
Loaded: loaded
(/usr/lib/systemd/system/mysqld.service; enabled; vendor preset:
disabled)
Active: active (running)
since Wed 2017-12-20 17:02:51 CST; 5s ago
Docs:
man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
mysqlimport
============================================
[li@MK1 20161230]$ tar -zcvf /tmp/zn.tar.gz
SQzn*
SQzn1701.csv
SQzn1702.csv
SQzn1703.csv
SQzn1704.csv
SQzn1705.csv
SQzn1706.csv
SQzn1707.csv
SQzn1708.csv
SQzn1709.csv
SQzn1710.csv
SQzn1711.csv
SQzn1712.csv
SQznMI.csv
[li@MK1 20161230]$
[li@MK1 20161230]$ tar -zcvf zn.tar.gz
SQzn*
tar (child): zn.tar.gz:无法 openSQzn1701.csv
: 权限不够
tar (child): Error is not recoverable: exiting now
SQzn1702.csv
[li@MK1 20161230]$
my.cnf 怎么修改都不起作用
============================
今天发现一个MySQL实例启动故障,处理过程如下:
发现mysql实例是关闭的,执行命令启动mysql实例时有警告:
# service mysql.server start
Warning: World-writable config file '/etc/my.cnf' is
ignored
Starting MySQL SUCCESS!
观察mysql的启动日志,在日志中显示:
151014 11:39:24 mysqld_safe Starting mysqld daemon with
databases from /data/mysql/data
Warning: World-writable config file '/etc/my.cnf' is
ignored
大概意思是权限全局可写,任何一个用户都可以写。mysql担心这种文件被其他用户恶意修改,所以忽略掉这个配置文件。
此时查询MySQL数据库中的配置,发现一些my.cnf配置的参数,在mysql实例中并没有生效。
这个是因为 /etc/my.cnf 也被修改为 777权限了:
# ls -la /etc/my.cnf
-rwxrwxrwx 1 root root 1120 Jul 31 10:28 /etc/my.cnf
/etc/my.cnf 权限过大,会影响实例不能启动,或者不能关闭,需要修改为 644.操作如下:
# ls -la /etc/my.cnf
-rwxrwxrwx 1 root root 1120 Jul 31 10:28 /etc/my.cnf
#
# chmod 644 /etc/my.cnf
# ls -la /etc/my.cnf
-rw-r--r-- 1 root root 1120 Jul 31 10:28 /etc/my.cnf
给mysql服务换一个不一样的名字(躲猫猫)
============================
进入目录 /etc/init.d
把名字为mysqld 或者mysql的shell脚本 cp 一份 如
mysql2
chmod 644 mysql2
chkconfig --add
mysql2
就好了用service 命令去启动吧!
# chkconfig --add mysql2
# chkconfig --list mysql2
mysql2
0:off
1:off 2:on
3:on 4:on
5:on
6:off
# service mysql2 start
Starting MySQL.. SUCCESS!
修改字符集
============================
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
character_set_server=utf8
[client]
default-character-set=latin1
[mysql]
default-character-set=latin1
[mysqld]
character_set_server=latin1
正确的给innodb表空间添加新的数据文件
====================================================
cnf里面原来的配置如下:
innodb_data_file_path =
/usr/local/mysql/data/ibdata1:18M
现在要增加一个新的数据文件,我想是200M,文件名是ibdata2,则上面的配置行修改成
innodb_data_file_path =
/usr/local/mysql/data/ibdata1:18M:autoextend;/mysql/data/ibdata2:50M:autoextend
看新文件目录与第一个不同,所以必须在重启数据库之前,确保目录 /mysql/data存在且有权限
innodb_data_file_path参数虐死你个菜鸟:给mysql主表空间增加文件,修改个参数,不是第一次肯定虐死你
我觉得只有饭桶才能写出这么弱智的代码和逻辑;
以下几种都是不支持的:
innodb_data_file_path=ibdata1:10M:autoextend;ibdata02:100M:autoextend
innodb_data_file_path=ibdata1:10M:autoextend;ibdata2:100M:autoextend
innodb_data_file_path=ibdata1:10M;ibdata02:100M:autoextend
innodb_data_file_path=ibdata1:10M;ibdata3:100M:autoextendinno
db_data_file_path=ibdata1:10M;ibdata2:100M:auto extend
唯一正确的是这种
innodb_data_file_path=ibdata1:10M;ibdata2:100M:autoextend
即使格式正确了,还是加不了文件
innodb_data_file_path=ibdata1:10M;ibdata2:100M:autoextend
看看mysql有多么弱,傻逼
2017-12-24T16:03:54.305226Z 0 [Note]
InnoDB: Need to create a new innodb_system data file
'ibdata2'.
2017-12-24T16:03:54.305280Z 0 [ERROR] InnoDB: The
innodb_system data file './ibdata1' is of a different size 768
pages (rounded down to MB) than the 640 pages specified in the .cnf
file!
2017-12-24T16:03:54.249641Z 0 [Note] InnoDB: PUNCH HOLE
support available
2017-12-24T16:03:54.249651Z 0 [Note] InnoDB: Mutexes and
rw_locks use GCC atomic builtins
2017-12-24T16:03:54.249657Z 0 [Note] InnoDB: Uses event
mutexes
2017-12-24T16:03:54.249665Z 0 [Note] InnoDB: GCC builtin
__atomic_thread_fence() is used for memory barrier
2017-12-24T16:03:54.249671Z 0 [Note] InnoDB: Compressed tables
use zlib 1.2.3
2017-12-24T16:03:54.249811Z 0 [Note] InnoDB: Using Linux
native AIO
2017-12-24T16:03:54.250597Z 0 [Note] InnoDB: Number of pools:
1
2017-12-24T16:03:54.250829Z 0 [Note] InnoDB: Using CPU crc32
instructions
2017-12-24T16:03:54.258084Z 0 [Note] InnoDB: Initializing
buffer pool, total size = 512M, instances = 1, chunk size =
128M
2017-12-24T16:03:54.287632Z 0 [Note] InnoDB: Completed
initialization of buffer pool
2017-12-24T16:03:54.295137Z 0 [Note] InnoDB: If the mysqld
execution user is authorized, page cleaner thread priority can be
changed. See the man page of setpriority().
2017-12-24T16:03:54.305226Z 0 [Note] InnoDB: Need to create a
new innodb_system data file 'ibdata2'.
2017-12-24T16:03:54.305280Z 0 [ERROR] InnoDB: The
innodb_system data file './ibdata1' is of a different size 768
pages (rounded down to MB) than the 640 pages specified in the .cnf
file!
2017-12-24T16:03:54.305297Z 0 [ERROR] InnoDB: Plugin
initialization aborted with error Generic error
2017-12-24T16:03:54.905734Z 0 [ERROR] Plugin 'InnoDB' init
function returned error.
2017-12-24T16:03:54.940973Z 0 [ERROR] Plugin 'InnoDB'
registration as a STORAGE ENGINE failed.
2017-12-24T16:03:54.940973Z 0 [ERROR] Failed to initialize
plugins.
2017-12-24T16:03:54.940973Z 0 [ERROR] Aborting
2017-12-24T16:03:54.940973Z 0 [Note] Binlog end
2017-12-24T16:03:54.940980Z 0 [Note] Shutting down plugin
'CSV'
2017-12-24T16:03:54.941249Z 0 [Note] /usr/sbin/mysqld:
Shutdown complete
open参数
============================
2017-12-25T08:00:15.387655Z 0 [Warning] Could not increase
number of max_open_files to more than 5000 (request: 12670)
2017-12-25T08:00:15.387811Z 0 [Warning] Changed limits:
table_open_cache: 1495 (requested 5330)
2017-12-25T08:00:15.557490Z 0 [Warning] TIMESTAMP with
implicit DEFAULT value is deprecated. Please use
--explicit_defaults_for_timestamp server option (see documentation
for more details).
2017-12-25T08:00:15.559303Z 0 [Warning] Insecure configuration
for --secure-file-priv: Data directory is accessible through
--secure-file-priv. Consider choosing a different directory.
2017-12-25T08:00:15.559312Z 0 [Warning] Insecure configuration
for --secure-file-priv: Location is accessible to all OS users.
Consider choosing a different directory.
2017-12-25T08:00:15.559349Z 0 [Note] /usr/sbin/mysqld (mysqld
5.7.20-log) starting as process 20183 ...
2017-12-25T08:00:15.562992Z 0 [Warning] option
'innodb-read-io-threads': unsigned value 256 adjusted to 64
2017-12-25T08:00:15.563383Z 0 [Warning] InnoDB: Using
innodb_file_format is deprecated and the parameter may be removed
in future releases. See
http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
[root@VM_64_101_centos etc]# cat my.cnf|grep open_
innodb_open_files=300
open_files_limit=5000
table_open_cache =5330
innodb_open_files=5000
Could not increase number of max_open_files to more than 5000
(request: 12670)
max_open_files = table_open_cache*2 +
2010
ex:12670 = 5330*2 + 2010
Changed limits: table_open_cache: 1495 (requested 5330)
table_open_cache =5330
这个包最好也装上,要不后面很多开发包装不了
mysql-community-libs-compat-5.7.20-1.el7.x86_64
=================================================
[root@VM_64_101_centos /]# rpm -e
mysql-community-libs-compat
error: Failed dependencies:
libmysqlclient.so.18()(64bit) is needed by (installed)
postfix-2:2.10.1-6.el7.x86_64
libmysqlclient.so.18()(64bit) is needed by (installed)
MySQL-python-1.2.5-1.el7.x86_64
libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by
(installed) postfix-2:2.10.1-6.el7.x86_64
libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by
(installed) MySQL-python-1.2.5-1.el7.x86_64
[root@VM_64_101_centos /]#
[root@VM_64_101_centos /]#
[root@VM_64_101_centos mysql]# ll
total 39988
-rw-r--r-- 1 root root 21358968 Sep 14 00:15
libmysqlclient.a
lrwxrwxrwx 1 root root
20 Dec 20 16:47 libmysqlclient.so ->
libmysqlclient.so.20
lrwxrwxrwx 1 root root
24 Dec 26
01:16 libmysqlclient.so.18 ->
libmysqlclient.so.18.1.0
-rwxr-xr-x 1 root root
9580608 Sep 14 00:07
libmysqlclient.so.18.1.0
lrwxrwxrwx 1 root root
24 Dec 20 16:47 libmysqlclient.so.20 ->
libmysqlclient.so.20.3.7
-rwxr-xr-x 1 root root 9884704 Sep 14 00:15
libmysqlclient.so.20.3.7
lrwxrwxrwx 1 root root
20 Dec 26 01:16 libmysqlclient_r.so.18 ->
libmysqlclient.so.18
lrwxrwxrwx 1 root root
24 Dec 26 01:16 libmysqlclient_r.so.18.1.0 ->
libmysqlclient.so.18.1.0
-rw-r--r-- 1 root root
44102 Sep 14 00:13 libmysqlservices.a
drwxr-xr-x 4 root root
4096 Dec 20 16:48 mecab
drwxr-xr-x 3 root root
4096 Dec 20 16:48 plugin
[root@VM_64_101_centos mysql]# ^C
