linux中mysql 5.5二进制文件安装详解
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-04 11:35:35 浏览: 评论:0
本文章来给大家介绍linux中mysql 5.5二进制文件安装方法,有需要了解的朋友根据下面方法即可实现安装mysql5了.
1、创建相关目录用户,代码如下:
- su – root
- groupadd mysql
- useradd -g mysql -p xifenfei -s /bin/bash -m mysql -d /opt/mysql
- MYSQL_BASE=/opt/mysql
- mkdir -p $MYSQL_BASE/product/5.5
- mkdir -p $MYSQL_BASE/mysqldata
- mkdir -p $MYSQL_BASE/mysqllog
- mkdir -p /var/run/mysqld/
- chmod -R 777 $MYSQL_BASE
- chown -R mysql:mysql $MYSQL_BASE
- chown -R mysql:mysql /var/run/mysqld
2、环境变量配置,代码如下:
- export MYSQL_BASE=/opt/mysql
- export basedir=$MYSQL_BASE/product/5.5
- export datadir=$MYSQL_BASE/mysqldata
- export LD_LIBRARY_PATH=$basedir/lib:/lib:/usr/lib:/usr/local/lib
- export TMPDIR=/tmp
- export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
- export PATH=$basedir:$basedir/bin:${PATH}:$LD_LIBRARY_PATH
3、调整mysql 用户系统限制(可选)
编辑文件:/etc/security/limits.conf 加入以下语句:
- mysql soft nproc 2047
- mysql hard nproc 16384
- mysql soft nofile 1024
- mysql hard nofile 65536
确认如下语句是否存在于/etc/pam.d/login,如果不存在请增加:
session required pam_limits.so
如果用户SHELL 用的是Bourne,Bash,或者Korn shell 修改/etc/profile,并增加如下内容,在SuSe 操作系统上,则需要修改/etc/profile.local,代码如下:
- if [ $USER = "mysql" ]; then
- if [ $SHELL = "/bin/ksh" ]; then
- ulimit -p 16384
- ulimit -n 65536
- else
- ulimit -u 16384 -n 65536
- fi
- fi
4、安装数据库
4.1)解压数据库至/opt/mysql/product/5.5中
4.2)安装数据,代码如下:
- [mysql@localhost ~]$ cd product/5.5/scripts/
- [mysql@localhost scripts]$ ./mysql_install_db –basedir=$basedir –datadir=$datadir –user=mysql
4.3)设置my.cnf参数,代码如下:
- vi /etc/my.cnf
- [mysqladmin]
- socket =/var/run/mysqld/mysqld.sock
- [client]
- port = 3306
- socket =/var/run/mysqld/mysqld.sock
- [mysqld]
- port = 3306
- socket = /var/run/mysqld/mysqld.sock
- user = mysql
- pid-file = /var/run/mysqld/mysqld.pid
- basedir = /opt/mysql/product/5.5
- datadir = /opt/mysql/mysqldata
- skip-external-locking = 1
- interactive_timeout = 1200
- wait_timeout = 1200
- character-set-server = utf8
- back_log = 500
- default_time_zone = '+08:00'
- max_connections = 1000
- max_connect_errors = 1000
- connect_timeout = 300
- table_open_cache = 100
- max_allowed_packet = 16M
- binlog_cache_size = 8M
- max_heap_table_size = 64M
- sort_buffer_size = 8M
- join_buffer_size = 8M
- thread_cache_size = 32
- thread_concurrency = 16
- query_cache_size = 0M
- default-storage-engine = INNODB
- thread_stack = 192K
- transaction_isolation = READ-COMMITTED
- tmp_table_size = 64M
- log-bin =/opt/mysql/mysqllog/mysqlbin
- log-error=/opt/mysql/mysqllog/mysqld.err
- expire_logs_days = 7
- binlog_format = ROW
- max_binlog_size = 300M
- slow_query_log = 1
- slow_query_log_file =/opt/mysql/mysqllog/mysqld-slow
- long_query_time = 10
- tmpdir = /tmp
- server-id = 1
- key_buffer_size = 8M
- read_buffer_size = 1M
- read_rnd_buffer_size = 1M
- bulk_insert_buffer_size = 1M
- myisam_sort_buffer_size = 128K
- innodb_additional_mem_pool_size = 16M
- innodb_buffer_pool_size = 2G
- innodb_data_file_path = ibdata1:1024M:autoextend
- innodb_autoextend_increment = 64
- innodb_file_per_table = 1
- innodb_data_home_dir = /opt/mysql/mysqldata
- innodb_file_io_threads = 4
- innodb_thread_concurrency = 16
- innodb_flush_log_at_trx_commit = 2
- innodb_log_buffer_size = 8M
- innodb_log_file_size = 512M
- innodb_log_files_in_group = 3
- innodb_max_dirty_pages_pct = 40
- innodb_lock_wait_timeout = 120
- innodb_locks_unsafe_for_binlog = 1
- innodb_autoinc_lock_mode = 2
- skip-name-resolve
- lower_case_table_names=1
- [mysqldump]
- quick
- max_allowed_packet = 16M
- [mysql] --phpfensi.com
- auto-rehash
- [myisamchk]
- key_buffer_size = 512M
- sort_buffer_size = 512M
- read_buffer = 8M
- write_buffer = 8M
- [mysqlhotcopy]
- interactive-timeout
- [mysqld_safe]
- open-files-limit = 8192
4.4)异常处理
4.4.1)直接通过mysqld_safe不能正常启动数据库,代码如下:
ln -s /opt/mysql/product/5.5 /usr/local/mysql
或者
ln -s /opt/mysql/product/5.5/bin/mysqld /usr/local/mysql/bin/mysqld
4.4.2)mysql_secure_installation不能正常执行.
1)执行:/opt/mysql/product/5.5/bin/mysql_secure_installation出现以下错误,解决方法(ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock)
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
2)修改mysql_secure_installation 脚本的do_query 函数,推荐处理方法,代码如下:
- do_query() {
- echo “$1″ >$command
- #sed ‘s,^,> ,’ < $command # Debugging
- # mysql --defaults-file=$config <$command ----此行修改如下:
- mysql --defaults-extra-file=$config <$command
- return $?
- }
5、添加开机启动服务
修改mysql.server文件,代码如下:
- basedir=/opt/mysql/product/5.5
- datadir=/opt/mysql/mysqldata
- [root@localhost ~]# cp /opt/mysql/product/5.5/support-files/mysql.server /etc/init.d/mysqld
- [root@localhost ~]# chkconfig –add mysqld
- [root@localhost ~]# chkconfig mysqld on
- [root@localhost ~]# chkconfig –list mysqld
- mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Tags: mysql5 5 mysql5 5二进制
相关文章
- ·CentOS6.4安装配置mysql 5.6服务器方法(2014-09-24)
- ·MySQL5.6 Using a password on the command line interface can be insecure(2014-09-24)
- ·mysql 5.5与5.6 timestamp 字段 DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIM(2014-09-27)
- ·Mysql5.5 InnoDB存储引擎设置(2014-09-28)
- ·mysql5.6设置sql_mode方法详解(2014-09-28)
- ·MYSQL开启慢查询与mysql5.6开启慢查询出错(2014-10-01)
- ·MySQL5.5默认编码的设置修改方法详解(2014-10-02)
- ·Linux中MySql5手动安装方法详解(2014-10-04)
- ·mysql5存储过程入门创建,删除,调用详解(2014-10-07)
- ·MySql 5.X创建用户并授权方法(2014-10-08)
- ·mysql5 插入中文乱码问题(2014-10-08)
- ·mysql5.5提示Could not initialize master info structure(2014-10-09)
- ·mysql5 sql-mode 引起的错误解决办法(2014-10-10)
- ·MySQL5的存储过程详细实例(2014-10-13)
- ·php调用mysql5存储过程方法(2014-10-14)
- ·MHA实现mysql5.6主从切换安装配置教程(2014-10-17)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)