linux下安装mysql5.6.26
来源:互联网 发布:用友软件代理商名单 编辑:程序博客网 时间:2024/06/05 02:22
1.环境描述
安装时用的Linux为rhel6.3 x86_64,用的MySQL为mysql5.6.26 x86_64,下载地址:www.oracle.com
安装方式为rpm二进制安装,所需要的两个mysql rpm安装包为:
MySQL-server-5.6.26-1.el6.x86_64.rpm
MySQL-client-5.6.26-1.el6.x86_64.rpm
上面的两个安装包也可以从以下的地址下载:
http://download.csdn.net/detail/jiaping0424/9503594
http://download.csdn.net/detail/jiaping0424/9503595
关于这两个包的作用和关系自己百度吧,这里不再赘述。
利用rpm二进制安装方式来安装mysql过程非常简单,rpm命令在安装时常用的参数是-hiv,其中i表示将安装指定的rmp软件包,v表示输出安装时的详细信息,h表示在安装期间出现“#”号来显示目前的安装进度。
2.检查并卸载已经存在的mysql
如果安装前系统已经存在相关组件,则在安装时会报冲突相关错误,这里避免报错先卸载与mysql相关的组件。
2.1.检查
[root@web1 ~]# rpm -qa|grep mysqlmysql-libs-5.1.61-4.el6.x86_64[root@web1 ~]#
2.2.卸载
[root@web1 ~]# rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64[root@web1 ~]# rpm -qa|grep mysql[root@web1 ~]#
3.安装mysql server和client
[root@web1 ~]# rpm -hiv MySQL-server-5.6.26-1.el6.x86_64.rpmwarning: MySQL-server-5.6.26-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:MySQL-server ########################################### [100%][root@web1 ~]# rpm -hiv MySQL-client-5.6.26-1.el6.x86_64.rpmwarning: MySQL-client-5.6.26-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:MySQL-client ########################################### [100%][root@web1 ~]#
4.拷贝并修改配置文件
[root@web1 ~]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
5.初始化MySQL及设置密码
[root@web1 ~]# /usr/bin/mysql_install_db[root@web1 ~]# service mysql startStarting MySQL.[确定][root@web1 ~]#
查看root账号密码
[root@web1 ~]# cat /root/.mysql_secret# The random password set for the root user at Fri Apr 22 00:52:07 2016 (local time): 3IYLCgGex2Y7KWvR[root@web1 ~]#
利用上面的密码登录:
[root@web1 ~]# mysql -uroot -p3IYLCgGex2Y7KWvRWarning: Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.26Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
修改密码为123456:
mysql> SET PASSWORD = PASSWORD('123456');Query OK, 0 rows affected (0.02 sec)mysql> exitBye
再用新密码登录:
[root@web1 ~]# mysql -uroot -p123456Warning: Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.6.26 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
6.允许远程登陆
[root@web1 ~]# mysql -uroot -p123456Warning: Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.6.26 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> select host,user,password from user;+-----------+------+-------------------------------------------+| host | user | password |+-----------+------+-------------------------------------------+| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 || web1 | root | *5B4AC10888F4F9D9A8CD55A78EF1EA2D0322B013 || 127.0.0.1 | root | *5B4AC10888F4F9D9A8CD55A78EF1EA2D0322B013 || ::1 | root | *5B4AC10888F4F9D9A8CD55A78EF1EA2D0322B013 |+-----------+------+-------------------------------------------+4 rows in set (0.00 sec)mysql> update user set password=password('123456') where user='root';Query OK, 3 rows affected (0.00 sec)Rows matched: 4 Changed: 3 Warnings: 0mysql> update user set host='%' where user='root' and host='localhost';Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> exitBye[root@web1 ~]#
7.设置开机自启动
[root@web1 ~]# chkconfig mysql on[root@web1 ~]# chkconfig --list | grep mysqlmysql 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭[root@web1 ~]#
8.MySQL的默认安装位置
/var/lib/mysql/ #数据库目录/usr/share/mysql #配置文件目录/usr/bin #相关命令目录/etc/init.d/mysql #启动脚本
9.修改字符集和数据存储路径
配置/etc/my.cnf文件、修改数据存放路径、mysql.sock路径以及默认编码utf-8
[root@web1 ~]# vi /etc/my.cnf[client] password = 123456 port = 3306 default-character-set=utf8 [mysqld] port = 3306 character_set_server=utf8character_set_client=utf8 collation-server=utf8_general_ci #(注意linux下mysql安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写) lower_case_table_names=1 #(设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384; ) max_connections=1000 [mysql] default-character-set = utf8
10.查看字符集
show variables like '%collation%';show variables like '%char%';
注:为了使博客更加完善,便于更好的分享,请读者为文章中的错误进行指正,博主会定期更正,谢谢!
Keep fighting.
Warrior
2016.4.27
– The End –
1 0
- linux下安装mysql5.6.26
- linux下安装MySQL5
- linux下mysql5安装日志
- linux下mysql5安装日志
- linux下安装mysql5.6
- linux下安装mysql5.5.43
- Linux下安装MySQL5.5
- Linux下安装MySQL5.7
- Linux下安装Mysql5.6.23
- Linux 下安装Mysql5.7
- linux下安装mysql5.6
- linux下安装mysql5.5.16
- linux下安装mysql5.7
- linux 下安装 mysql5.6.30
- mysql5.6 linux下安装
- linux下安装mysql5.7
- linux下安装mysql5.7
- linux下安装mysql5.7
- php简简单单搞定中英文混排字符串截取,只需2行代码!
- html中的meta详解
- .Net开源网络爬虫Abot介绍
- python使用matplotlib绘图
- Leetcode 36. Valid Sudoku & 37. Sudoku Solver
- linux下安装mysql5.6.26
- spring+sprinmvc+mybatis基本整合(二)--基于spring注解mybais非注解非Mapper接口方式
- mysql小知识笔记
- std::swap 不支持 std::auto_ptr 类型参数
- Leetcode 41. First Missing Positive
- Android中怎样使用计步器传感器 "TYPE_STEP_DETECTOR"
- round() Function in Python and Matlab
- Leetcode 56. Merge Intervals & 57. Insert Interval
- java基础(29)--深入剖析Java中的装箱和拆箱