linux下mysql二进制包安装

centos 6.3下mysql 5.6.28 二进制包安装步骤:
1.添加用户组和用户
[root@repl1 local]# groupadd mysql
[root@repl1 local]# cat /etc/group |grep mysql
mysql:x:500:
[root@repl1 local]# 
[root@repl1 local]# useradd -r -g mysql -s /bin/false mysql
[root@repl1 local]# export LANG=zh_cn.GB2312
[root@repl1 local]# id mysql
uid=496(mysql) gid=500(mysql) groups=500(mysql)
[root@repl1 local]# 
2.解压mysql二进制包
[root@repl1 local]# tar -zxvf mysql-5.6.28-linux-glibc2.5-x86_64.tar.gz
3.建立一个软连接
[root@repl1 local]# ln -s mysql-5.6.28-linux-glibc2.5-x86_64 mysql
[root@repl1 local]# ll
total 305564
drwxr-xr-x.  2 root root      4096 Dec 15 16:23 bin
drwxr-xr-x.  2 root root      4096 Sep 23  2011 etc
drwxr-xr-x.  2 root root      4096 Sep 23  2011 games
drwxr-xr-x.  2 root root      4096 Dec 15 16:13 include
drwxr-xr-x.  6 root root      4096 Dec 16 15:37 keepalived
drwxr-xr-x. 12 root root      4096 Dec 15 16:13 lib
drwxr-xr-x.  2 root root      4096 Sep 23  2011 lib64
drwxr-xr-x.  2 root root      4096 Sep 23  2011 libexec
drwxr-xr-x.  5 root root      4096 Dec 15 16:13 man
lrwxrwxrwx.  1 root root        34 Jan 14 09:19 mysql -> mysql-5.6.28-linux-glibc2.5-x86_64
drwxr-xr-x. 13 root root      4096 Jan 14 09:05 mysql-5.6.28-linux-glibc2.5-x86_64
-rw-r--r--.  1 root root 312829487 Jan 13 10:49 mysql-5.6.28-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x.  3 root root      4096 Dec 17 16:25 nutcracker
drwxr-xr-x.  6 root root      4096 Dec 15 17:33 redis
drwxr-xr-x.  2 root root      4096 Dec 17 15:24 sbin
drwxr-xr-x.  5 root root      4096 Nov 27 18:12 share
drwxr-xr-x.  2 root root      4096 Sep 23  2011 src

4.建立配置文件 /etc/my.cnf
[mysqld]
datadir=/var/data/mysql
socket=/var/data/mysql/mysql.sock
user=mysql

5.建立数据目录
[root@repl1 var]# mkdir -p data/mysql
[root@repl1 var]# chown mysql:mysql -R data
[root@repl1 var]# ll
total 96
drwxr-xr-x.  2 root  root   4096 Nov 27 18:16 account
drwxr-xr-x. 14 root  root   4096 Nov 27 18:20 cache
drwxr-xr-x.  2 root  root   4096 Jun 22  2012 crash
drwxr-xr-x.  2 root  root   4096 Feb 22  2012 cvs
drwxr-xr-x.  3 mysql mysql  4096 Jan 14 09:55 data

权限修改
[root@repl1 mysql]# chown -R mysql .
[root@repl1 mysql]# chgrp -R mysql .
[root@repl1 mysql]# ls -al
total 188
drwxr-xr-x. 13 mysql mysql   4096 Jan 14 10:03 .
drwxr-xr-x. 17 root  root    4096 Jan 14 09:19 ..
-rw-r--r--.  1 mysql mysql  17987 Nov 16 17:38 COPYING
-rw-r--r--.  1 mysql mysql 105684 Nov 16 18:45 INSTALL-BINARY
-rw-r--r--.  1 mysql mysql   2496 Nov 16 17:38 README
drwxr-xr-x.  2 mysql mysql   4096 Jan 14 09:04 bin
drwxr-xr-x.  3 mysql mysql   4096 Jan 14 09:05 data
drwxr-xr-x.  2 mysql mysql   4096 Jan 14 09:05 docs
drwxr-xr-x.  3 mysql mysql   4096 Jan 14 09:05 include
drwxr-xr-x.  3 mysql mysql   4096 Jan 14 09:05 lib
drwxr-xr-x.  4 mysql mysql   4096 Jan 14 09:04 man
-rw-r--r--.  1 mysql mysql    943 Jan 14 10:03 my-new.cnf
-rw-r--r--.  1 mysql mysql    943 Jan 14 09:26 my.cnf
drwxr-xr-x. 10 mysql mysql   4096 Jan 14 09:05 mysql-test
drwxr-xr-x.  2 mysql mysql   4096 Jan 14 09:05 scripts
drwxr-xr-x. 28 mysql mysql   4096 Jan 14 09:04 share
drwxr-xr-x.  4 mysql mysql   4096 Jan 14 09:05 sql-bench
drwxr-xr-x.  2 mysql mysql   4096 Jan 14 10:15 support-files

6.初始化执行mysql_install_db脚本
[root@repl1 mysql]#  ./scripts/mysql_install_db --user=mysql
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "zh_cn.GB2312"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Installing MySQL system tables...2016-01-14 10:23:49 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-14 10:23:49 0 [Note] ./bin/mysqld (mysqld 5.6.28) starting as process 5257 ...
2016-01-14 10:23:49 5257 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-14 10:23:49 5257 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-14 10:23:49 5257 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-14 10:23:49 5257 [Note] InnoDB: Memory barrier is not used
2016-01-14 10:23:49 5257 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-14 10:23:49 5257 [Note] InnoDB: Using Linux native AIO
2016-01-14 10:23:49 5257 [Note] InnoDB: Not using CPU crc32 instructions
2016-01-14 10:23:49 5257 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-14 10:23:49 5257 [Note] InnoDB: Completed initialization of buffer pool
2016-01-14 10:23:49 5257 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-01-14 10:23:49 5257 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-01-14 10:23:49 5257 [Note] InnoDB: Database physically writes the file full: wait...
2016-01-14 10:23:49 5257 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-01-14 10:23:49 5257 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-01-14 10:23:50 5257 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-01-14 10:23:50 5257 [Warning] InnoDB: New log files created, LSN=45781
2016-01-14 10:23:50 5257 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-01-14 10:23:50 5257 [Note] InnoDB: Doublewrite buffer created
2016-01-14 10:23:50 5257 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-14 10:23:50 5257 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-01-14 10:23:50 5257 [Note] InnoDB: Foreign key constraint system tables created
2016-01-14 10:23:50 5257 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-01-14 10:23:50 5257 [Note] InnoDB: Tablespace and datafile system tables created.
2016-01-14 10:23:50 5257 [Note] InnoDB: Waiting for purge to start
2016-01-14 10:23:50 5257 [Note] InnoDB: 5.6.28 started; log sequence number 0
2016-01-14 10:23:50 5257 [Note] Binlog end
2016-01-14 10:23:50 5257 [Note] InnoDB: FTS optimize thread exiting.
2016-01-14 10:23:50 5257 [Note] InnoDB: Starting shutdown...
2016-01-14 10:23:52 5257 [Note] InnoDB: Shutdown completed; log sequence number 1625977 OK
Filling help tables...2016-01-14 10:23:52 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-14 10:23:52 0 [Note] ./bin/mysqld (mysqld 5.6.28) starting as process 5282 ...
2016-01-14 10:23:52 5282 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-14 10:23:52 5282 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-14 10:23:52 5282 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-14 10:23:52 5282 [Note] InnoDB: Memory barrier is not used
2016-01-14 10:23:52 5282 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-14 10:23:52 5282 [Note] InnoDB: Using Linux native AIO
2016-01-14 10:23:52 5282 [Note] InnoDB: Not using CPU crc32 instructions
2016-01-14 10:23:52 5282 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-14 10:23:52 5282 [Note] InnoDB: Completed initialization of buffer pool
2016-01-14 10:23:52 5282 [Note] InnoDB: Highest supported file format is Barracuda.
2016-01-14 10:23:52 5282 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-14 10:23:52 5282 [Note] InnoDB: Waiting for purge to start
2016-01-14 10:23:52 5282 [Note] InnoDB: 5.6.28 started; log sequence number 1625977
2016-01-14 10:23:52 5282 [Note] Binlog end
2016-01-14 10:23:52 5282 [Note] InnoDB: FTS optimize thread exiting.
2016-01-14 10:23:52 5282 [Note] InnoDB: Starting shutdown...
2016-01-14 10:23:54 5282 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
  ./bin/mysqladmin -u root password 'new-password'
  ./bin/mysqladmin -u root -h repl1 password 'new-password'
Alternatively you can run:
  ./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
  cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
  cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
  http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
WARNING: Found existing config file ./my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as ./my-new.cnf,
please compare it with your file and take the changes you need.
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

[root@repl1 mysql]# chown -R root .
[root@repl1 mysql]# ll -al
total 188
drwxr-xr-x. 13 root mysql   4096 Jan 14 10:03 .
drwxr-xr-x. 17 root root    4096 Jan 14 09:19 ..
-rw-r--r--.  1 root mysql  17987 Nov 16 17:38 COPYING
-rw-r--r--.  1 root mysql 105684 Nov 16 18:45 INSTALL-BINARY
-rw-r--r--.  1 root mysql   2496 Nov 16 17:38 README
drwxr-xr-x.  2 root mysql   4096 Jan 14 09:04 bin
drwxr-xr-x.  3 root mysql   4096 Jan 14 09:05 data
drwxr-xr-x.  2 root mysql   4096 Jan 14 09:05 docs
drwxr-xr-x.  3 root mysql   4096 Jan 14 09:05 include
drwxr-xr-x.  3 root mysql   4096 Jan 14 09:05 lib
drwxr-xr-x.  4 root mysql   4096 Jan 14 09:04 man
-rw-r--r--.  1 root mysql    943 Jan 14 10:23 my-new.cnf
-rw-r--r--.  1 root mysql    943 Jan 14 09:26 my.cnf
drwxr-xr-x. 10 root mysql   4096 Jan 14 09:05 mysql-test
drwxr-xr-x.  2 root mysql   4096 Jan 14 09:05 scripts
drwxr-xr-x. 28 root mysql   4096 Jan 14 09:04 share
drwxr-xr-x.  4 root mysql   4096 Jan 14 09:05 sql-bench
drwxr-xr-x.  2 root mysql   4096 Jan 14 10:15 support-files

7.启动mysql
[root@repl1 mysql]# ./bin/mysqld_safe --user=mysql &
[1] 5326
[root@repl1 mysql]# 160114 10:25:37 mysqld_safe Logging to '/var/data/mysql/repl1.err'.
160114 10:25:37 mysqld_safe Starting mysqld daemon with databases from /var/data/mysql
[root@repl1 mysql]# ls
[root@ndbcluster1 tmp]# ps -ef |grep mysql
root     12993     1  0 Jan06 ?        00:56:04 ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial
root     13065     1  0 Jan06 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/ndbcluster1.pid
mysql    13262 13065  0 Jan06 ?        00:36:49 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/ndbcluster1.err --pid-file=/var/lib/mysql/ndbcluster1.pid

8.登录
[root@repl1 mysql]# ./bin/mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
登录报错了,通过socketd登录,但/tmp下没有socket文件,原因是由于我在参数文件中执定socket
用指定socket进行登录
[root@repl1 mysql]# ./bin/mysql --socket=/var/data/mysql/mysql.sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.28 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)
或者通过网络登录
[root@repl1 mysql]# ./bin/mysql --protocol=tcp  -uroot -p
修改root密码
[root@repl1 mysql]# ./bin/mysqladmin  --socket=/var/data/mysql/mysql.sock -u root password '123456';
Warning: Using a password on the command line interface can be insecure.
由于这样登录比较麻烦
可以把参数文件中的socket注释掉,登录默认读取socket文件/tmp/mysql.sock
然后重启mysql 
再次登录正常
停止mysql可以使用
./bin/mysqladmin -uroot -p123456 shutdown

启动停止登录都需要指定mysql全目录
把mysql的bin目录添加环境变量中/etc/profile
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile 环境变量生效

把mysql启动设置为服务
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
[root@repl1 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@repl1 mysql]# chmod 755 /etc/rc.d/init.d/mysqld
[root@repl1 mysql]# chkconfig --add mysqld
[root@repl1 mysql]# 
[root@repl1 ~]# chkconfig --list mysqld 
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@repl1 ~]# service mysqld status
MySQL running (5687)                                       [纭甝
验证
[root@repl1 ~]# service mysqld stop
Shutting down MySQL..                                      [纭甝
[root@repl1 ~]# service mysqld start
Starting MySQL.                                            [纭甝
[root@repl1 ~]# 

添加系统重启mysql启动也可以通过在/etc/rc.local中添加如下:
/usr/local/mysql/bin/mysqld_safe --user=mysql &

mysql 官方的安装:
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server










 









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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值