mysql安装for linux(二进制)



1、下载

下载页面是  http://dev.mysql.com/downloads/mysql/


http://cdn.mysql.com/Downloads/MySQL-5.6/mysql- 5.6.21-linux-glibc2.5-x86_64.tar.gz


如果出现新的版本,直接更改这个链接中的版本号即可,如现在应改为


http://cdn.mysql.com/Downloads/MySQL-5.6/mysql- 5.6.23-linux-glibc2.5-x86_64.tar.gz


2、复制到linux中,并解压

 tar xvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz -C /usr/local 

[root@zw oradata]# mv /usr/local/mysql-5.6.23-linux-glibc2.5-x86_64/ mysql

3、创建Mysql的用户和组
 
[root@zw oradata]# groupadd dba
[root@zw oradata]# useradd -r -g dba mysql

userdel -r test 删除test用户
 
4 # 修改目录权限,指定给 mysql用户和用户组

[root@zw oradata]# chown -R mysql:dba /usr/local/mysql/


5.设置环境变量 
export PATH=/usr/local/mysql/bin:$PATH



6、安装DB  初始化命令只能在 mysql 这个目录下执行,不然会报错

[root@zw oradata]# /usr/local/mysql/scripts/mysql_install_db --user=mysql  --basedir=/usr/local/mysql  --datadir=/usr/local/mysql/data/  
 
[root@zw oradata]# cp my.cnf /etc

7.修改配置文件
 
[root@zw oradata] # cp my.cnf /etc/my.cnf

/usr/local/mysql

[root@zw oradata] # vi /etc/my.cnf


[mysqld]中添加:

basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
server_id = 1
log-bin=mysql-bin



8 :启动mySQL服务,

 /usr/local/mysql/bin/mysqld_safe --user=root&
  
 
9、连接mysql

#使用MySQL命令的全路径。
[root@zw oradata]# /usr/local/mysql/bin/mysql -u root -p
Enter password:上面设置的password
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.5.40-log MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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>


10. 设置root密码

 ./bin/mysqladmin -u root password 123


10、启动、关闭mysql

[root@zw oradata]#/usr/local/mysql/support-files/mysql.server start
[root@zw oradata]#/usr/local/mysql/support-files/mysql.server stop

如果想执行 service mysql start or restart stop 命令咋办的? 在不能老#./mysql.server start
解决方法: 将 mysql.server  复制一份到 /etc/rc.d/init.d 下并改名 mysql 或建个连接文件
假设当前目录为 /etc/rc.d/init.d

[root@zw oradata]# cp  /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

 启动:
 ① service mysql start     前提是执行了cp support-files/mysql.server /etc/init.d/mysql
 ② ./etc/init.d/mysql start
 ③ ./usr/local/mysql/bin/mysqld_safe --user=root&
 ④ /usr/local/mysql/support-files/mysql.server start
  
关闭:
①. service mysql stop
②./etc/init.d/mysql stop
③./usr/local/mysql/bin/mysqladmin -u root -p shutdown
④./usr/local/mysql/support-files/mysql.server stop

11、设置开机启动项

[root@zw oradata]# cp support-files/mysql.server /etc/init.d/mysql            上面已经做了可以省略
[root@zw oradata]# chkconfig --add mysql
 
 

你可能感兴趣的:(linux,mysql二进制安装,mysql安装for)