MySQL5.5.24编译安装

MySQL5.5.24编译安装(亲测)首先从官网下载mysql.tar.gz 压缩包
当然也有mysql的rpm包 rpm 包安装起来就比较简单啦

由于mysql5 以上版本都开始用cmake方式编译安装
所以我们要先安装好cmake
yum –y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml*
ncurses-devel libmcrypt* libtool-ltdl-devel* cmake  make

 


编译安装mysql5.5
首先添加用户及组
groupadd  mysql
useradd -g mysql mysql -s /sbin/nologin
创建mysql安装文件夹及数据存放路径
mkdir -p  /usr/local/mysql
mkdirt -p /var/data/mysqldata
改变mysql数据文件夹的属性
chown -R mysql:mysql
开始解压安装
tar -zxf mysql-5.5.24.tar.gz
cd  mysql-5.5.24
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \  -----mysql安装路径
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \      ------mysql监听sock位置
-DDEFAULT_CHARSET=utf8 \                     ----mysql字符编码方式
-DDEFAULT_COLLATION=utf8_general_ci \        --默认排序规则
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \       额外支持字符集
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \      
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql \                -----mysql数据存放位置
-DMYSQL_USER=mysql \                        ------mysql 安装用户名
-DMYSQL_TCP_PORT=3306                       ------mysql 监听端口
 如果没报错  继续

 

cmake -DCMAKE_INSTALL_PREFIX=/data/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306

make
make install

安装完后要进行数据库的初始化
cd /usr/local/mysql
cp support-files/my-medium.cnf /etc/my.cnf  复制配置文件
cp support-files/mysql-server /etc/init.d/mysqld 复制到系统
chmod 755 /etc/init.d/mysqld       修改属性
chkconfig --add /etc/init.d/mysqld   -------添加为服务
chkconfig  mysqld --level 235 on  设置在235  级别是开机自动运行

 

mysql_install_db

应该是你安装完成mysql之后 在bin目录下的

1
/usr/local/mysql/bin/mysql_install_db  --user=mysql --datadir= /usr/local/mysql/var  --skip-name-resolve

一般是这样

这个是初始化mysql数据库的命令     非安装mysql



[client]
#password       = your_password
port            = 3306
socket          = /data/mysql/mysql.sock
default-character-set=utf8
# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port            = 3306
character_set_server=utf8
basedir=/data/mysql
datadir=/data/mysql/data
socket          = /data/mysql/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

 


启动mysql
service mysqld start
如果报错
Starting MySQL. ERROR! The server quit without updating PID file (/data/mysql/rhelubuntu.com.pid).

则修改
vim  /etc/init.d/mysqld
修改basedir=/usr/local/mysql             -----mysql安装位置
修改datadir=/var/data/mysqldata          -----mysql数据文件存放位置
一般修改好这个再重新启动mysql应该不会报错了

 

修改mysql 管理员密码
mysqladmin -u root  password
输入新密码

 

 

 

 


mysql 远程登录
grant all on *.* to root@'%' identified by'pwd@123'

(.代表所有的数据库,当然也可以选择其他的数据库)
(root 是用户名,一样也可以选择其他用户名)
(%代表所有的ip地址)
(这个‘password’里面的内容是root用户的密码);
flush privileges;  刷新权限

 

mysql  添加用户
grant all privileges on  test.* on z460@'%' identifiled by ‘password’
///其中all  privileges 表示所有的权限 ,当然我们也可以授予select ,update,drop ,create等权限
其中test  表示test数据库 
z460表示 用户名
%表示所有的ip地址
password表示z460用户的密码
flush privileges ;

 

 


02.mysql 5.5.24安装步骤  03. 04.下载:  05.   06.wget ftp://ftp.easynet.be/mysql/Downloads/MySQL-5.5/mysql-5.5.24.tar.gz  07.yum install gcc gcc-c++ libtool autoconf -y   08.yum install automake imake libxml2-devel expat-devel ncurses-devel cmake bison -y  09.tar zxvf mysql-5.5.24.tar.gz  10.cd mysql-5.5.24  11.cmake  \  12.-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \  13.-DMYSQL_DATADIR=/home/mysql/ \  14.-DWITH_MYISAM_STORAGE_ENGINE=1 \  15.-DWITH_INNOBASE_STORAGE_ENGINE=1 \  16.-DWITH_ARCHIVE_STORAGE_ENGINE=1 \  17.-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \  18.-DENABLED_LOCAL_INFILE=1 \  19.-DDEFAULT_CHARSET=utf8 \  20.-DDEFAULT_COLLATION=utf8_general_ci \  21.-DEXTRA_CHARSETS=all \  22.-DWITH_SSL=system \  23.-DMYSQL_TCP_PORT=3306 24.make  25.make install  26.cd /usr/local/mysql  27.chown -R mysql .  28.chgrp -R mysql .  29.cp support-files/mysql.server /etc/init.d/mysqld  30.chmod +x /etc/init.d/mysqld  31. 32./usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql &  33.vim /etc/my.cnf  34.[client]  35.port    = 3306 36.socket    = /tmp/mysql.sock  37.   38.# The MySQL server  39.[mysqld]  40.port    = 3306 41.socket    = /tmp/mysql.sock  42.datadir         = /data/mysql  43.   44.skip-name-resolve  45.skip-external-locking  46.   47.table_open_cache = 70 48.read_buffer_size = 256K 49.read_rnd_buffer_size = 512K 50.thread_concurrency=16 51.########################### INNODB ############################  52.innodb_file_per_table=1 53.innodb_buffer_pool_size=20M 54.innodb_flush_log_at_trx_commit=0 55.#init_connect='SET autocommit=0' 56.innodb_log_file_size=40M 57.innodb_additional_mem_pool_size=16M 58.innodb_log_buffer_size=6M 59.innodb_doublewrite=0 60.innodb_max_dirty_pages_pct=80 61.innodb_flush_method=O_DIRECT 62.innodb_thread_concurrency=0 63.   64.####################### Connections ##########################  65.#back_log = 500 66.max_connections=1024 67.max_connect_errors=99999 68.max_allowed_packet = 2M 69.table_cache=4096 70.thread_cache=64 71.open_files_limit = 10000 72.net_buffer_length = 8K 73.   74.####################### Buffer Size ###########################  75.key_buffer = 3072M 76.max_heap_table_size = 32M 77.myisam_sort_buffer_size = 8M 78.#query_cache_size = 128M 79.sort_buffer_size = 512K 80.tmp_table_size = 64M 81.   82.###############################################################  83.interactive_timeout=30 84.wait_timeout=30 85.connect_timeout=10 86.   87.#slow-query-log  88.#long_query_time=2 89.slow-query-log  90.slow_launch_time=2 91.slow-query-log-file=/data/mysql/db001-slow.log  92.   93.######################## Master-Slave ########################  94.   95.server-id=1 96.   97.log-bin=mysql-bin  98.binlog_format=mixed 99.log_slave_updates= 1 100.   101.expire_logs_days=30 102.lower_case_table_names=1 103.   104.slave-skip-errors=all 105.   106.##############################################################  107.[mysqldump]  108.quick  109.max_allowed_packet = 16M 110.   111.[mysql]  112.no-auto-rehash  113.   114.[isamchk]  115.key_buffer = 8M 116.sort_buffer_size = 8M 117.   118.[myisamchk]  119.key_buffer = 8M 120.sort_buffer_size = 8M 121.   122.[mysqlhotcopy]  123.interactive-timeout  124.##增加系统服务  125./sbin/chkconfig --add mysqld  126./sbin/chkconfig mysqld on  127./sbin/service mysqld start  128.netstat -tnlp |grep 3306  129.export PATH=$PATH:/usr/local/mysql/bin/  130. 131.mysql 5.5.24  132.主从配置  133.master 192.168.0.211  134.slave 192.168.0.210  135. 136.在master的配置文件中加上  137.server-id = 1 138.binlog-do-db = test01 139.binlog-ignore-db = mysql 140.在slave的配置文件上加上  141.server-id = 2 142.relay-log=server02-relay-bin  143.replicate-do-db = test01 144.replicate-ignore-db=mysql 145.relay-log-index=slave-relay-bin.index  146.###master的信息不用再加到slave的配置文件中 否则重启mysql引起找不到pid文件 master的信息只在从库中执行change语句里面执行  147.分别重启数据库  148.在master上看一下以下信息  149.mysql> show master status;  150.+------------------+----------+--------------+------------------+  151.| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |  152.+------------------+----------+--------------+------------------+  153.| mysql-bin.000008 | 199 | test01 | mysql |  154.+------------------+----------+--------------+------------------+  155.并执行一下语句:  156.mysql> create database test01;  157.mysql> GRANT REPLICATION SLAVE,REPLICATION CLIENT,RELOAD,SUPER ON *.* TO'slave'@'192.168.0.210' IDENTIFIED BY '123456';  158.mysql> Grant ALL PRIVILEGES ON test01.* TOslave@'%' IDENTIFIED BY '123456';  159.在slave上执行一下语句  160.mysql> CHANGE MASTER TO MASTER_HOST='192.168.0.211', MASTER_PORT=3306,MASTER_USER='slave', MASTER_PASSWORD='123456',master_log_file = 'mysql-bin.000008', master_log_pos = 199;  161.mysql> slave start;  162.mysql> show slave status\G  163.能看到Slave_IO_Running: Yes  164.Slave_SQL_Running: Yes说明同步成功  165. 166. 167.mysql5.1与5.5主从配置的差异  168.1.master信息不再在从库的配置文件中指定,而是直接在从库的sql命令中使用change master语句指定  169. 170.2.Server-id的规则:  171.Server ID. On the master and each slave, you must use the server-id option to establish a unique replication ID in the range from 1 to 232 – 1. “Unique” means that each ID must be different from every other ID in use by any other replication master or slave.  172.主库ID为1,从库id的取值范围为2-232 – 1 但每个slave的id必须唯一  173. 174.此外官方推荐的配置配置文件中指出:  175.# required unique id between 2 and 2^32 – 1 #从库ID取值范围为2-232 – 1  176.# (and different from the master) #必须和主库区别开  177.# defaults to 2 if master-host is set #默认设置为2 如果只有一个从库  178.# but will not function as a slave if omitted #如果对id不做设置,从库将不起作用  179. 180.3。在5.5从机中,skip-slave-errors=all是继续有效,但是官方文档给出的解释如下:  181.? --slave-skip-errors=[err_code1,err_code2,...|all]  182.Normally, replication stops when an error occurs on the slave. This gives you the opportunity to resolve the inconsistency in the  183.data manually. This option tells the slave SQL thread to continue replication when a statement returns any of the errors listed in  184.the option value.  185.正常情况下,当从库复制出现出现错误时,复制将暂停,这样就有了解决数据不一致的机会。此选项的作用是,当此选项值等于mysql返回的错误码[err_code* 、ALL]时复制继续进行  186.Do not use this option unless you fully understand why you are getting errors. If there are no bugs in your replication setup and  187.client programs, and no bugs in MySQL itself, an error that stops replication should never occur. Indiscriminate use of this option  188.results in slaves becoming hopelessly out of synchrony with the master, with you having no idea why this has occurred.  189.不建议使用此选项,除非你可以断定什么原因导致了这些错误,如果在复制设置、客户端程序、以及mysql本身无bugs,能使复制进程停止的错误是不可能发生的,滥用此选项将会导致无法理想的与主库同步,而且你会对此不同步的原因将毫不知情  190.4.MySQL 5.5的二进制日志记录格式为MAXED  191.mysql> select @@session.binlog_format;  192.+-------------------------+  193.| @@session.binlog_format |  194.+-------------------------+  195.| MIXED |  196.+-------------------------+  197.1 row in set (0.00 sec)

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lizhongren

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值