码迷,mamicode.com
首页 > 数据库 > 详细

利用rpm包手把手教你安装MySQL(MySQL-server-5.6.23 for CentOS6.5_64bit)

时间:2015-03-30 18:49:07      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:

转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/44753455


一、检查操作系统上是否安装了MySQL
[root@mydb1 backup]# rpm -qa |grep mysql
qt-mysql-4.6.2-26.el6_4.x86_64
mysql-5.1.71-1.el6.x86_64
mysql-server-5.1.71-1.el6.x86_64
mysql-devel-5.1.71-1.el6.x86_64
mysql-libs-5.1.71-1.el6.x86_64


二、删除MyQL(redhat6.3服务器自带的mysql-libs是mysql-libs-5.1.61-4.el6.x86_64,可能会和高版本的mysql-libs有冲突)
yum remove mysql-libs




三、RPM安装MySQL(用root用户安装,不需要提前建mysql组和mysql用户,安装mysql-server过程中会自动创建)
[root@mydb1 backup]# rpm -pql MySQL-server-5.6.23-1.el6.x86_64.rpm | more 
[root@mydb1 backup]# rpm -ivh MySQL-server-5.6.23-1.el6.i686.rpm
[root@mydb1 backup]# rpm -ivh MySQL-client-5.6.23-1.el6.x86_64.rpm




四、创建安装目录
mkdir -p /u01/app/mysql/data/mysql3306/data
mkdir -p /u01/app/mysql/data/mysql3306/log
mkdir -p /u01/app/mysql/log/mysql3306/iblog
mkdir -p /u01/app/mysql/log/mysql3306/binlog
mkdir -p /u01/app/mysql/data/mysql3306/tmp




五、配置my.cnf
cp /usr/my.cnf /u01/app/mysql/data/mysql3306/my.cnf


vi /u01/app/mysql/data/mysql3306/my.cnf
[client]
port=3306
socket=/u01/app/mysql/data/mysql3306/run/mysql.sock


[mysql]
port=3306
promprt=\\u@\\d \\r:\\m:\\s>


[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
explicit_defaults_for_timestamp=true


#dir
innodb_log_group_home_dir=/u01/app/mysql/log/mysql3306/iblog
innodb_data_home_dir=/u01/app/mysql/log/mysql3306/iblog
basedir=/usr
datadir=/u01/app/mysql/data/mysql3306/data
tmpdir=/u01/app/mysql/data/mysql3306/tmp
slave_load_tmpdir=/u01/app/mysql/data/mysql3306/tmp
log-error=/u01/app/mysql/data/mysql3306/log/alert.log
slow_query_log_file=/u01/app/mysql/data/mysql3306/log/slow.log
relay_log_info_file=/u01/app/mysql/log/mysql3306/binlog/relay-log.info
master-info-file=/u01/app/mysql/log/mysql3306/binlog/master.info
socket=/u01/app/mysql/data/mysql3306/run/mysql.sock
log-bin=/u01/app/mysql/log/mysql3306/binlog/binlog
relay-log=/u01/app/mysql/log/mysql3306/binlog/relaylog


innodb_force_recovery=0






四、执行MySQL安装脚本
sh init3306.sh


rm -rf /u01/app/mysql/mysql3306/data/*
rm -rf /u01/app/mysql/log/mysql3306/iblog/*
rm -rf /u01/app/mysql/log/mysql3306/binlog/*
chmod -R 777 /u01/app/mysql/data/mysql/3306/data/*
chmod -R 777 /u01/app/mysql/log/mysql3306/iblog/*
chmod -R 777 /u01/app/mysql/log/mysql3306/binlog/*
chmod 755 /u01/app/mysql/data/mysql3306/my.cnf
mysql_install_db --defaults-file=/u01/app/mysql/data/mysql3306/my.cnf --basedir=/usr/ --datadir=/u01/app/mysql/data/mysql3306/data




五、查是否有MySQL服务,如没有添加mysql到服务开机启动
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
查看开机启动设置是否成功
[root@mydb1 ~]# chkconfig --list | grep mysql
mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off


六、启动MySQL
[root@mydb1 ~]# service mysql start
Starting MySQL SUCCESS! 
  
七、查看MySQL运行状态的方法
 [root@mydb1 ~]# service mysql status
 SUCCESS! MySQL running (4104)
 
八、查MySQL初始密码
[root@mydb1 ~]# cat /root/.mysql_secret 
# The random password set for the root user at Mon Mar 30 15:04:58 2015 (local time): B15xIBTq3xAoGRVx


九、登录MySQL
[root@mydb1 ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.23


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> 


十、修改密码
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> SET PASSWORD = PASSWORD(‘guoyJoe123‘);
Query OK, 0 rows affected (0.00 sec)


mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)


如果要远程访问root用户,如下命令!
mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘guoyJoe123‘ WITH GRANT OPTION;

利用rpm包手把手教你安装MySQL(MySQL-server-5.6.23 for CentOS6.5_64bit)

标签:

原文地址:http://blog.csdn.net/guoyjoe/article/details/44753455

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!