本文将为您提供关于CentOS-7-x86_64安装配置64位Mysql步骤的详细介绍,同时,我们还将为您提供关于64位centos6安装mysql-5.7.13-linux-glibc2.5-x86
本文将为您提供关于CentOS-7-x86_64安装配置64位Mysql步骤的详细介绍,同时,我们还将为您提供关于64位centos6安装mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz、CentOS 5.4 x86_64 编译安装 MySQL 完全笔记、CentOS 5.5 安装 mysql-5.1.53-linux-x86_64 及主从复制集群配置、centos 6.3 x86_64安装32位JDK的问题的实用信息。
本文目录一览:- CentOS-7-x86_64安装配置64位Mysql步骤
- 64位centos6安装mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
- CentOS 5.4 x86_64 编译安装 MySQL 完全笔记
- CentOS 5.5 安装 mysql-5.1.53-linux-x86_64 及主从复制集群配置
- centos 6.3 x86_64安装32位JDK的问题
CentOS-7-x86_64安装配置64位Mysql步骤
centos7 64位裸机安装配置MysqL过程
1、先检查系统是否装有MysqL,如果有删除
(正常情况下裸机是没有的)
rpm -qa | grep MysqL
这里返回空值,说明没有安装
这里执行安装命令是无效的,因为centos-7默认是Mariadb,所以执行以下命令只是更新Mariadb数据库(不需要执行)
yum install MysqL
删除可用
yum remove MysqL
2、下载MysqL的repo源
wget http://repo.MysqL.com/MysqL-community-release-el7-5.noarch.rpm
-bash: wget: command not found
说明没有安装wget
安装wget命令是:
yum -y install wget
3.安装MysqL-community-release-el7-5.noarch.rpm包
rpm -ivh MysqL-community-release-el7-5.noarch.rpm
4、安装MysqL-server
yum install MysqL-server
出现以下说明安装成功:
查看是否启动
ps -ef |grep MysqL
以下说明没有启动
service MysqLd start
出现以下,说明启动成功
5.设置登录密码
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的拥有者改为当前用户:
chown -R openscanner:openscanner /var/lib/MysqL
然后,重启服务:
service MysqLd restart
如果报chown: 无效的用户: "openscanner:openscanner"
错误,更换命令
chown root /var/lib/MysqL/
MysqL -u root -p
use MysqL;
update user set password=password('root') where user='root';
exit;
重启MysqL服务后才生效
service MysqLd restart
登录测试密码:
6、查询数据库编码格式,确保是 UTF-8
show variables like "%char%";
出现以下情况,不需要修改
需要修改编码格式为UTF-8时,进入MySQL命令行后 输入
set names utf8;
7.设置远程登录
加入以下命令行,为root添加远程连接的能力。链接密码为 “root”(不包括双引号)
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";
7.1实验环境下
可以永久性关闭防火墙,然后进行操作
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running) systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动
7.2 开发环境下
需要配置防火墙
开放3306端口号firewalld 防火墙(centos-7)运行命令,并重启:
firewall-cmd --zone=public --add-port=3306/tcp --permanent firewall-cmd --reload
重启MysqL:
service MysqLd restart
64位centos6安装mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
1. 从官网下载 MysqL-5.7.13-linux-glibc2.5-x86_64.tar.gz
2. 创建MysqL的用户组/用户,data目录及其用户目录
# groupadd MysqL # useradd -g MysqL -d /opt/my/MysqL MysqL # mkdir /opt/my/MysqL/data
3. 解压安装包并将解压包里的内容拷贝到MysqL的安装目录/home/MysqL
# tar -xzvf MysqL-5.7.9-linux-glibc2.5-x86_64.tar.gz
# mv MysqL-5.7.9-linux-glibc2.5-x86_64 MysqL
4. 初始化MysqL数据库
<codehttps://www.jb51.cc/tag/dis/" target="_blank">display: block; padding: 0px; color: inherit; Box-sizing: border-Box; font-family: "Source Code Pro",monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;"># cd /opt/my/MysqL</span> <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;"># ./bin/MysqL_install_db --user=MysqL --basedir=/opt/my/MysqL --datadir=/opt/my/MysqL/data</span> <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">2015</span>-<spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">11</span>-<spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">10</span> <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">02</span>:<spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">09</span>:<spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">17</span> [WARNING] MysqL_install_db <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">is</span> deprecated. Please consider switching <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">to</span> MysqLd <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">--initialize</span> <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">23</span> [WARNING] The bootstrap <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">log</span> <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">isn't</span> empty: <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">23</span> [WARNING] <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">10</span>T10:<spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">18.114182</span>Z <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">0</span> [Warning] <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">--bootstrap is deprecated. Please consider using --initialize instead</span> <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">18.129343</span>Z <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">0</span> [Warning] Changed limits: max_open_files: <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">1024</span> (requested <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">5000</span>) <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">18.129408</span>Z <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">0</span> [Warning] Changed limits: table_open_cache: <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">431</span> (requested <spanhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box;">2000</span>)</code><ulhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221,221,221); list-style: none; text-align: right; background-color: rgb(238,238,238);"><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">1</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">2</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">3</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">4</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">5</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">6</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">7</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">8</li></ul><ulhttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221,238);"><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">1</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">2</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">3</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">4</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">5</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">6</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">7</li><lihttps://www.jb51.cc/tag/Box/" target="_blank">Box-sizing: border-Box; padding: 0px 5px;">8</li></ul>
p.s.: MysqL5.7新特性:由上面可以看出,MysqL_install_db
已经不再推荐使用了,建议改成MysqLd --initialize
完成实例初始化。
# ./bin/MysqLd --user=MysqL --basedir=/opt/my/MysqL --datadir=/opt/my/MysqL/data --initialize
改用MysqLd --initialize
后,如果 datadir 指向的目标目录下已经有数据文件,会出现如下提示:
# cd /home/MysqL # ./bin/MysqL_install_db --user=MysqL --basedir=/home/MysqL --datadir=/home/MysqL/data 2015-11-10 02:09:17 [WARNING] MysqL_install_db is deprecated. Please consider switching to MysqLd --initialize 2015-11-10 02:09:23 [WARNING] The bootstrap log isn't empty: 2015-11-10 02:09:23 [WARNING] 2015-11-10T10:09:18.114182Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead 2015-11-10T10:09:18.129343Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000) 2015-11-10T10:09:18.129408Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
p.s.: MysqL5.7新特性:由上面可以看出,MysqL_install_db
已经不再推荐使用了,建议改成MysqLd --initialize
完成实例初始化。
# ./bin/MysqLd --user=MysqL --basedir=/home/MysqL --datadir=/home/MysqL/data --initialize改用
MysqLd --initialize
后,如果 datadir 指向的目标目录下已经有数据文件,会出现如下提示:
# ./MysqLd --user=MysqL --basedir=/home/MysqL --datadir=/home/MysqL/data --initialize 2016-04-08T01:46:53.153530Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-04-08T01:46:53.155856Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. 2016-04-08T01:46:53.155879Z 0 [ERROR] Aborting
<spanhttps://www.jb51.cc/tag/Now/" target="_blank">Nowrap; font-family: "microsoft yahei"; background-color: rgb(255,255,255);">由上可知, 我们需要清空</span><a target=_blank target="_blank" href="http://lib.csdn.net/base/MysqL"title="MysqL知识库"https://www.jb51.cc/tag/Now/" target="_blank">Nowrap; font-family: "microsoft yahei"; text-decoration: none; color: rgb(223,52,52); font-weight: bold; background-color: rgb(255,255);">MysqL</a><spanhttps://www.jb51.cc/tag/Now/" target="_blank">Nowrap; font-family: "microsoft yahei"; background-color: rgb(255,255);">的data目录, 执行清空命令如下:</span>
# cd /opt/my/MysqL/data # rm -fr *
然后重新执行初始化命令如下:
# ./bin/MysqLd --user=MysqL --basedir=/home/MysqL --datadir=/home/MysqL/data --initialize 2016-04-08T01:47:57.556677Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-04-08T01:47:59.945537Z 0 [Warning] InnoDB: New log files created,LSN=45790 2016-04-08T01:48:00.333528Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2016-04-08T01:48:00.434908Z 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: ece26421-fd2b-11e5-a1e3-00163e001e5c. 2016-04-08T01:48:00.440125Z 0 [Warning] Gtid table is not ready to be used. Table 'MysqL.gtid_executed' cannot be opened. 2016-04-08T01:48:00.440904Z 1 [Note] A temporary password is generated for root@localhost: **mjT,#x_5sW
牢记上面的随机密码, 如上“,下面我们修改密码时需要用到。
5. 检测下是否能启动MysqL服务
# cd /home/MysqL # ./support-files/MysqL.server start Starting MysqL.. SUCCESS!
若改用了, 则在启动服务时会出现如下错误:
# ./support-files/MysqL.server start ./support-files/MysqL.server: line 276: cd: /usr/local/MysqL: No such file or directory Starting MysqL ERROR! Couldn't find MysqL server (/usr/local/MysqL/bin/MysqLd_safe)
这时候我们需要修改/support-files/MysqL.server
文件的basedir和datadir目录路径为我们正确的MysqL的basedir和datadir路径, 如下:
# vim support-files/MysqL.server -------------------------- ... basedir=/home/MysqL datadir=/home/MysqL/data ... -------------------------- # ./support-files/MysqL.server start Starting MysqL.. SUCCESS!
6. 创建软链接
# ln -s /opt/my/MysqL/bin/MysqL /usr/bin/MysqL
7. 创建配置文件
将默认生成的my.cnf备份
# mv /etc/my.cnf /etc/my.cnf.bak
进入MysqL的安装目录支持文件目录
# cd /opt/my/MysqL/support-files
拷贝配置文件模板为新的MysqL配置文件,
# cp my-default.cnf /etc/my.cnf
可按需修改新的配置文件选项, 不修改配置选项, MysqL则按默认配置参数运行.
如下是我修改配置文件/etc/my.cnf, 设置编码为utf8以防乱码
# vim /etc/my.cnf [MysqLd] basedir = /opt/my/MysqL datadir = /home/MysqL/data character_set_server=utf8 init_connect='SET NAMES utf8' [client] default-character-set=utf8
8. 配置MysqL服务开机自动启动
拷贝启动文件到/etc/init.d/下并重命令为MysqLd
# cp /opt/my/MysqL/support-files/MysqL.server /etc/init.d/MysqLd
增加执行权限
# chmod 755 /etc/init.d/MysqLd
检查自启动项列表中没有MysqLd这个,如果没有就添加MysqLd
:
# chkconfig --list MysqLd # chkconfig --add MysqLd
设置MysqL在345等级自动启动
# chkconfig --level 345 MysqLd on
或用这个命令设置开机启动:
# chkconfig MysqLd on
9. MysqL服务的启动/重启/停止
启动MysqL服务
# service MysqLd start
重启MysqL服务
# service MysqLd restart
停止MysqL服务
# service MysqLd stop
10. 初始化MysqL用户root的密码
先将MysqL服务停止
# service MysqLd stop
进入MysqL安装目录, 执行:
# cd /home/MysqL # ./bin/MysqLd_safe --skip-grant-tables --skip-networking& [1] 6225 [root@localhost MysqL]# 151110 02:46:08 MysqLd_safe Logging to '/home/MysqL/data/localhost.localdomain.err'. 151110 02:46:08 MysqLd_safe Starting MysqLd daemon with databases from /home/MysqL/data
另外打开一个终端(p.s. 如果是ssh连接登录的,另外创建一个ssh连接即可), 执行操作如下:
# MysqL -u root MysqL Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MysqL monitor. Commands end with ; or \g. Your MysqL connection id is 2 Server version: 5.7.9 MysqL Community Server (GPL) copyright (c) 2000,2015,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> use MysqL; Database changed MysqL> UPDATE user SET password=PASSWORD('123456') WHERE user='root'; ERROR 1054 (42S22): UnkNown column 'password' in 'field list' MysqL> update user set authentication_string = PASSWORD('123456') where user = 'root'; Query OK,1 row affected,1 warning (0.02 sec) Rows matched: 1 Changed: 1 Warnings: 1 MysqL> flush privileges; Query OK,0 rows affected (0.00 sec) MysqL> \s -------------- MysqL Ver 14.14 distrib 5.7.9,for linux-glibc2.5 (x86_64) using EditLine wrapper Connection id: 2 Current database: MysqL Current user: root@ SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.7.9 MysqL Community Server (GPL) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /tmp/MysqL.sock Uptime: 4 min 47 sec Threads: 1 Questions: 43 Slow queries: 0 Opens: 127 Flush tables: 1 Open tables: 122 Queries per second avg: 0.149 -------------- MysqL> exit; Bye
到此, 设置完MysqL用户root的密码且确保MysqL编码集是utf8,注意上面, 新版本的MysqL.user表里的密码字段是authentication_string
快捷键ctrl + c
停止# ./bin/MysqLd_safe ...
命令, 重新启动MysqL服务, 用新密码连接MysqL:
# service MysqLd start Starting MysqL SUCCESS! [root@localhost bin]# MysqL -uroot -p Enter password: Welcome to the MysqL monitor. Commands end with ; or \g. Your MysqL connection id is 3 Server version: 5.7.9 copyright (c) 2000,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> use MysqL; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. MysqL > exit; Bye
咦?又要我改密码, 我们通过MysqLadmin来修改密码, 先输入原密码, 再设置新密码, 总算可以了吧!!!
# cd /home/MysqL # ./bin/MysqLadmin -u root -p password Enter password: New password: Confirm new password: Warning: Since password will be sent to server in plain text,use ssl connection to ensure password safety. # MysqL -uroot -p Enter password: Welcome to the MysqL monitor. Commands end with ; or \g. Your MysqL connection id is 6 Server version: 5.7.9 MysqL Community Server (GPL) copyright (c) 2000,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> use MysqL; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MysqL>或直接:
# ./bin/MysqLadmin -uroot -p'**mjT,#x_5sW' password '123456' 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.
其中,**mjT,#x_5sW
就是我们在使用MysqLd --initialize
时牢记下的随机密码
11. MysqL远程授权
格式如下:
MysqL> grant all [privileges] on db_name.table_name to 'username'@'host' identified by 'password';
示例如下:
MysqL> grant all privileges on *.* to 'root'@'%' identified by '123456'; Query OK,0 rows affected,1 warning (0.04 sec) MysqL> FLUSH PRIVILEGES; Query OK,0 rows affected (0.00 sec) MysqL>
或用
MysqL> grant all on *.* to 'root'@'%' identified by '123456';
到此, 完成了MysqL的安装 及配置!!!
我自己用的下面这种:
安装完MysqL 之后,登陆以后,不管运行任何命令,总是提示这个
step 1:SET PASSWORD = PASSWORD(‘your new password‘);
step 2:ALTER USER‘root‘@‘localhost‘ PASSWORD EXPIRE NEVER;
step 3:flush privileges;
完成以上三步退出再登,使用新设置的密码就行了,以上除了红色的自己修改成新密码外,其他原样输入即可
CentOS 5.4 x86_64 编译安装 MySQL 完全笔记
MySQL编译安装笔记大前提,你的Linux系统要搭建好GCC的编译环境。使用CentOS的话可以:yum -y install gccyum -y install gcc-c+
MySQL编译安装笔记
大前提,你的Linux系统要搭建好GCC的编译环境。
使用CentOS的话可以:
yum -y install gcc
yum -y install gcc-c++
添加MySQL用户组和用户
grounadd mysql
useradd -g mysql mysql
MySQL编译安装依赖的软件包:
cd /tmp
wget
tar -zvxf ncurses-5.7.tar.gz
cd ncurses-5.7
./configure --prefix=/usr --with-shared --without-debug
make
make install
修改MySQL最大连接数,解开MySQL的原代码,进入里面的sql目录修改mysqld.cc找到下面一行:
{"max_connections", OPT_MAX_CONNECTIONS,
"The number of simultaneous clients allowed.", (gptr*) &max_connections,(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 16384, 0, 1,0},
把它改为:
{"max_connections", OPT_MAX_CONNECTIONS,"The number of simultaneous clients allowed.", (gptr*) &max_connections,(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 1500, 1, 16384, 0, 1,0},
编译安装MySQL:
cd /tmp
wget
tar -zvxf mysql-5.5.2-m2.tar.gz
cd mysql-5.5.2-m2
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti -fomit-frame-pointer -ffixed-ebp"
./configure --prefix=/usr/local/mysql --enable-assembler --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-plugins=partition,innobase,myisammrg
make
make install
在CentOS上安装mysql时,可能会停顿一段时间(mysql-test),多等等就过去了
安装完成后,修改目录权限:
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
建立一些必要的目录:
mkdir -p /usr/local/mysql/data
mkdir -p /usr/local/mysql/binlog
mkdir -p /usr/local/mysql/relaylog
chown -R mysql:mysql /usr/local/mysql
使用mysql用户帐号的身份建立数据表(也可以说初始化mysql的数据库):
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
创建MySQL的配置文件,,配置文件名通常为my.cnf:
vi /usr/local/mysql/my.cnf
输入以下内容并保存:
[client]
character-set-server = utf8
port = 3306
socket = /tmp/mysql.sock
[mysqld]
character-set-server = utf8
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user = mysql
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
log-error = /usr/local/mysql/mysql_error.log
pid-file = /usr/local/mysql/mysql.pid
open_files_limit = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
thread_concurrency = 8
query_cache_size = 512M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
long_query_time = 3
log-slave-updates
log-bin = /usr/local/mysql/binlog/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 1G
relay-log-index = /usr/local/mysql/relaylog/relaylog
relay-log-info-file = /usr/local/mysql/relaylog/relaylog
relay-log = /usr/local/mysql/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
interactive_timeout = 120
wait_timeout = 120
skip-name-resolve
master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
#master-host = 192.168.1.2
#master-user = username
#master-password = password
#master-port = 3306
server-id = 1
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 512M
innodb_data_file_path = ibdata1:256M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
#log-slow-queries = /usr/local/mysql/slow.log
#long_query_time = 10
[mysqldump]
quick
max_allowed_packet = 32M
创建管理MySQL数据库的shell脚本:
vi /usr/local/mysql/mysql
输入以下内容并保存(这里的用户名root和密码123456接下来的步骤会创建):
#!/bin/sh
mysql_port=3306
mysql_username="root"
mysql_password="123456"
function_start_mysql()
{
printf "Starting MySQL...\n"
/bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf 2>&1 > /dev/null &
}
function_stop_mysql()
{
printf "Stoping MySQL...\n"
/usr/local/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/mysql.sock shutdown
}
function_restart_mysql()
{
printf "Restarting MySQL...\n"
function_stop_mysql
sleep 5
function_start_mysql
}
function_kill_mysql()
{
kill -9 $(ps -ef | grep ''bin/mysqld_safe'' | grep ${mysql_port} | awk ''{printf $2}'')
kill -9 $(ps -ef | grep ''libexec/mysqld'' | grep ${mysql_port} | awk ''{printf $2}'')
}
if [ "$1" = "start" ]; then
function_start_mysql
elif [ "$1" = "stop" ]; then
function_stop_mysql
elif [ "$1" = "restart" ]; then
function_restart_mysql
elif [ "$1" = "kill" ]; then
function_kill_mysql
else
printf "Usage: /usr/local/mysql/mysql {start|stop|restart|kill}\n"
fi
赋予MySQL数据库的shell脚本可执行权限:
chmod +x /usr/local/mysql/mysql
启动MySQL:
/usr/local/mysql/mysql start
通过命令行登录管理MySQL服务器(提示输入密码时直接回车):
/usr/local/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
输入以下SQL语句,创建一个具有root权限的用户(root)和密码(123456):
GRANT ALL PRIVILEGES ON *.* TO ''root''@''localhost'' IDENTIFIED BY ''123456'';
GRANT ALL PRIVILEGES ON *.* TO ''root''@''127.0.0.1'' IDENTIFIED BY ''123456'';
停止MySQL命令:
/usr/local/mysql/mysql stop
CentOS 5.5 安装 mysql-5.1.53-linux-x86_64 及主从复制集群配置
设置Mysql的主从复制的主要用途:1 做备份机器,一旦主服务器崩溃,可以直接启用从服务器作为主服务器2 可以直接锁定从服务器的表
设置Mysql的主从复制的主要用途:
1 做备份机器,一旦主服务器崩溃,可以直接启用从服务器作为主服务器
2 可以直接锁定从服务器的表只读,然后做备份数据,这样不会影响主服务器的服务
3 可以处理读写数据库的负载均衡
要点:
从服务器一般需要设置只读,否则容易产生错误导致同步失败
wget ://mysql.mirror.tw/
tar -C /usr/local -xzf mysql-5.1.53-linux-i686-glibc23.tar.gz
cd /usr/local
ln -s mysql-5.1.53-linux-i686-glibc23 mysql
tar -C /usr/local -xzf mysql-5.1.53-linux-x86_64-glibc23.tar.gz
cd /usr/local
ln -s mysql-5.1.53-linux-x86_64-glibc23 mysql
cd /usr/local/mysql
cp support-files/my-huge.cnf my.cnf
mv /etc/my.cnf ~/
mv /etc/rc.d/init.d/mysqld ~/
修改server-id = 1为服务器ip地址最后几位,或者其它数值:
vim my.cnf
server-id = 8108
max_allowed_packet = 64M
max_connections=800
character-set-server=utf8
expire_logs_days = 60
binlog_format=mixed
innodb_log_files_in_group=2
default_table_type = INNODB
innodb_data_home_dir = /opt/data/mysql/
innodb_data_file_path = ibdata1:2000M;ibdata2:2000M;ibdata3:20M:autoextend
innodb_log_group_home_dir = /opt/data/mysql/
# 4G RAM
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
innodb_log_buffer_size = 4M
innodb_flush_log_at_trx_commit=0
innodb_thread_concurrency=8
innodb_flush_method=O_DIRECT
# perform
tmp_table_size = 512M
max_heap_table_size=128M
slow_query_log
#slow_query_log_file=mysql-slow.log
long_query_time=1
log-error=mysqld.log
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#————————————–
# 32G RAM
max_allowed_packet = 64M
innodb_buffer_pool_size = 24G
#————————————-
/usr/sbin/groupadd -g 502 mysql
/usr/sbin/useradd -u 502 -g mysql mysql
mkdir -p /opt/data/mysql/
chown mysql.mysql /opt/data/mysql/
cd /usr/local/mysql/
scripts/mysql_install_db –user=mysql
chown -R root .
chown -R mysql data
chgrp -R mysql .
#chmod -R u+rw data
cd /opt/data/mysql/
chown mysql.mysql /opt/data/mysql/
cd /usr/local/mysql/
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
#/sbin/chkconfig –del mysqld
/sbin/chkconfig –add mysqld
/sbin/chkconfig –level 345 mysqld on
/sbin/chkconfig –list mysqld
echo "/usr/local/mysql/lib" >> /etc/ld.so.conf
cat /etc/ld.so.conf
ldconfig
/etc/rc.d/init.d/mysqld stop
/etc/rc.d/init.d/mysqld start
mkdir -p /var/lib/mysql/
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
#/usr/local/mysql/bin/mysqld_safe &
mkdir -p /var/run/mysqld/
chown mysql /var/run/mysqld/
#加入mysql到路径
echo pathmunge /usr/local/mysql/bin after > /etc/profile.d/mysql.sh
#执行一下,保证mysql在路径环境变量中
. /etc/profile
或者
vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin
PATH=/usr/local/mysql/bin:$PATH
tail -50 /opt/data/mysql/*.err
slave上的配置
修改server-id = 1为服务器ip地址最后几位,,或者其它数值,必须保证唯一性:
vim my.cnf
server-id = 8168
max_connections=600
character-set-server=utf8
binlog_format = "ROW"
default_table_type = innodb
relay-log-purge=1
#slave-skip-errors=1062,1053
skip-slave-start
replicate-ignore-db=mysql
innodb_data_home_dir = /opt/data/mysql/
innodb_data_file_path = ibdata1:2000M;ibdata2:2000M:autoextend
innodb_log_group_home_dir = /opt/data/mysql/
在master服务器上配置复制账号权限:
GRANT REPLICATION SLAVE ON *.* TO ''replication''@''%'' IDENTIFIED BY ''slavepass'';
flush privileges;
在slave服务器上配置master服务器信息:
CHANGE MASTER TO MASTER_HOST=''10.8.8.108'', MASTER_USER=''replication'', MASTER_PASSWORD=''slavepass'';
start slave;
centos 6.3 x86_64安装32位JDK的问题
我的是64位系统所以遇到下面的问题1:
修复/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory问题
1、在64系统里执行32位程序如果出现
/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory,安装下glic即可
yum install glibc.i686
2、出现
error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory,安装zlib即可
yum install zlib.i686
今天关于CentOS-7-x86_64安装配置64位Mysql步骤的分享就到这里,希望大家有所收获,若想了解更多关于64位centos6安装mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz、CentOS 5.4 x86_64 编译安装 MySQL 完全笔记、CentOS 5.5 安装 mysql-5.1.53-linux-x86_64 及主从复制集群配置、centos 6.3 x86_64安装32位JDK的问题等相关知识,可以在本站进行查询。
本文标签: