MySQL-client-5.6.36-1.linux_glibc2.5.x86_64.rpm安装详解

这篇博客是初学的时候写的,现在更新一个更简单的在线安装

#卸载mariadb
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
#sudo rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
rpm -qa | grep mariadb
#下载mysql的repo源
wget -P /root http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
#通过rpm安装
rpm -ivh mysql-community-release-el7-5.noarch.rpm
#安装mysql
yum install mysql-server
#授权
chown -R mysql:mysql /var/lib/mysql
#开启Mysql服务
service mysqld start
#用root用户连接登录mysql:
mysql -uroot
#重置mysql密码
use mysql;
update user set password=password('root') where user='root';
flush privileges;

 

---------------------------------------------------------------

centos6.8已经安装了mysql,所以要卸载掉

查看命令 rpm -qa | grep mysql 

注意:MySQL区分大小写 grep mysql 和grep MySQL 是不一样的!!

卸载命令 yum remomve mysql(刚才查看到的安装包)

 

全文用的是绝对路径,所以不要在乎[root@master mysql]

我用的是CentOs6系统,首先下载MySql安装包,如下:

MySQL-client-5.6.36-1.linux_glibc2.5.x86_64.rpm
MySQL-server-5.6.36-1.linux_glibc2.5.x86_64.rpm

百度云链接:mysql-5.6.36

密码:qdsi

这个包的默认解压路径是/usr/share/mysql

[root@master ~]# cd /usr/local/mysql/

[root@master mysql]# ls
MySQL-client-5.6.36-1.linux_glibc2.5.x86_64.rpm
MySQL-server-5.6.36-1.linux_glibc2.5.x86_64.rpm
[root@master mysql]# rpm -ivh MySQL-server-5.6.36-1.linux_glibc2.5.x86_64.rpm   //安装mysql-server
warning: MySQL-server-5.6.36-1.linux_glibc2.5.x86_64.rpm: Header V3 DSA/SHA1 


Signature, key ID 5072e1f5: NOKEY
Preparing...                                                            


(100%########################################### [100%]
   1:MySQL-server                                                       (  


1%########################################### [100%]
2017-04-12 00:26:36 0 [Note] Ignoring --secure-file-priv value as server is running with --

bootstrap.
2017-04-12 00:26:36 0 [Note] /usr/sbin/mysqld (mysqld 5.6.36) starting as process 8502 ...
2017-04-12 00:26:36 8502 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-04-12 00:26:36 8502 [Note] InnoDB: The InnoDB memory heap is disabled
2017-04-12 00:26:36 8502 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-04-12 00:26:36 8502 [Note] InnoDB: Memory barrier is not used
2017-04-12 00:26:36 8502 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-04-12 00:26:36 8502 [Note] InnoDB: Using Linux native AIO
2017-04-12 00:26:36 8502 [Note] InnoDB: Not using CPU crc32 instructions
2017-04-12 00:26:36 8502 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-04-12 00:26:36 8502 [Note] InnoDB: Completed initialization of buffer pool
2017-04-12 00:26:36 8502 [Note] InnoDB: The first specified data file ./ibdata1 did not 


exist: a new database to be created!
2017-04-12 00:26:36 8502 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-04-12 00:26:36 8502 [Note] InnoDB: Database physically writes the file full: wait...
2017-04-12 00:26:37 8502 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-04-12 00:26:38 8502 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-04-12 00:26:39 8502 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-04-12 00:26:39 8502 [Warning] InnoDB: New log files created, LSN=45781
2017-04-12 00:26:39 8502 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-04-12 00:26:39 8502 [Note] InnoDB: Doublewrite buffer created
2017-04-12 00:26:39 8502 [Note] InnoDB: 128 rollback segment(s) are active.
2017-04-12 00:26:39 8502 [Warning] InnoDB: Creating foreign key constraint system 

tables.
2017-04-12 00:26:39 8502 [Note] InnoDB: Foreign key constraint system tables created
2017-04-12 00:26:39 8502 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-04-12 00:26:39 8502 [Note] InnoDB: Tablespace and datafile system tables created.
2017-04-12 00:26:39 8502 [Note] InnoDB: Waiting for purge to start
2017-04-12 00:26:39 8502 [Note] InnoDB: 5.6.36 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2017-04-12 00:26:40 8502 [Warning] 'user' entry 'root@master' ignored in --skip-name-


resolve mode.
2017-04-12 00:26:40 8502 [Warning] 'proxies_priv' entry '@ root@master' ignored in --


skip-name-resolve mode.
2017-04-12 00:26:40 8502 [Note] Binlog end
2017-04-12 00:26:40 8502 [Note] InnoDB: FTS optimize thread exiting.
2017-04-12 00:26:40 8502 [Note] InnoDB: Starting shutdown...
2017-04-12 00:26:41 8502 [Note] InnoDB: Shutdown completed; log sequence number 

1625977

2017-04-12 00:26:41 0 [Note] Ignoring --secure-file-priv value as server is running with --


bootstrap.
2017-04-12 00:26:41 0 [Note] /usr/sbin/mysqld (mysqld 5.6.36) starting as process 8524 ...
2017-04-12 00:26:41 8524 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-04-12 00:26:41 8524 [Note] InnoDB: The InnoDB memory heap is disabled
2017-04-12 00:26:41 8524 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-04-12 00:26:41 8524 [Note] InnoDB: Memory barrier is not used
2017-04-12 00:26:41 8524 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-04-12 00:26:41 8524 [Note] InnoDB: Using Linux native AIO
2017-04-12 00:26:41 8524 [Note] InnoDB: Not using CPU crc32 instructions
2017-04-12 00:26:41 8524 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-04-12 00:26:41 8524 [Note] InnoDB: Completed initialization of buffer pool
2017-04-12 00:26:41 8524 [Note] InnoDB: Highest supported file format is Barracuda.
2017-04-12 00:26:41 8524 [Note] InnoDB: 128 rollback segment(s) are active.
2017-04-12 00:26:41 8524 [Note] InnoDB: Waiting for purge to start
2017-04-12 00:26:42 8524 [Note] InnoDB: 5.6.36 started; log sequence number 1625977
2017-04-12 00:26:42 8524 [Note] Binlog end
2017-04-12 00:26:42 8524 [Note] InnoDB: FTS optimize thread exiting.
2017-04-12 00:26:42 8524 [Note] InnoDB: Starting shutdown...
2017-04-12 00:26:43 8524 [Note] InnoDB: Shutdown completed; log sequence number 

1625987

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.


You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.


Also, the account for the anonymous user has been removed.


In addition, you can run:


  /usr/bin/mysql_secure_installation


which will also give you the option of removing the test database.
This is strongly recommended for production servers.


See the manual for more instructions.


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 /usr/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 /usr/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@master mysql]# netstat -nat    //检测端口是否启用
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 0.0.0.0:22                 0.0.0.0:*                   LISTEN    //22号端口在监听状态
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      
tcp        1      0 192.168.32.132:58955        219.93.37.75:80             CLOSE_WAIT 
[root@master mysql]# service mysql start //启动mysql服务    
Starting MySQL.Logging to '/usr/share/mysql/mysqldata/master.err'.
.. SUCCESS! 
[root@master mysql]# rpm -ivh MySQL-client-5.6.36-1.linux_glibc2.5.x86_64.rpm     //安装mysql客户端
warning: MySQL-client-5.6.36-1.linux_glibc2.5.x86_64.rpm: Header V3 DSA/SHA1 


Signature, key ID 5072e1f5: NOKEY
Preparing...                                                            


(100%########################################### [100%]
   1:MySQL-client                                                       (  


1%########################################### [100%]

 

 

 

 

然后将此目录下的my-default.cnf 复制到/etc/my.cnf

[root@master ~]# cp /usr/share/mysql/my-default.cnf  /etc/my.cnf        //将配置文件复制到/etc/my.cnf 

打开/etc/my.cnf  并配置

[root@master ~]# vim /etc/my.cnf

详细的配置项看:http://www.jb51.net/article/48082.htm

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

重点配置是红色字体

[client]
port=3306
socket=/var/lib/mysql/mysql.sock

[mysqld]
character_set_server = utf8
port = 3306
datadir = /usr/share/mysql/mysqldata
socket =/var/lib/mysql/mysql.sock
explicit_defaults_for_timestamp=true
skip_name_resolve
log_bin_trust_function_creators = 1
event_scheduler=ON


lower_case_table_names=1
federated

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M


# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
max_connections = 1000
max_connect_errors = 10000



# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
server_id =0
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysql]
default-character-set = utf8

保存退出;

注意:若出现PID not found 的情况,可以注释掉配置文件中的default-character-set=utf8

然后关闭后台进程,重新启动mysql服务。

在安装mysql server的过程中,它会随机生成一个默认的密码,位置在: /root/.mysql_secret 


打开这个文件之后就可以看到随机的密码了。


[root@master mysql]# cat /root/.mysql_secret 
# The random password set for the root user at Tue Apr 11 01:35:47 2017 (local time): 


HwPKi2jYCHdPOdR1           //系统生成的密码


# The random password set for the root user at Wed Apr 12 00:26:39 2017 (local time): 


#####密码#####  //默认的密码

[root@master mysql]# mysql -uroot -p

Enter password: #####密码#####  //默认的密码
mysql> SET Password=PASSWORD('newpassword') //修改密码

mysql> FLUSH PRIVILEGES;
mysql> quit
[root@master mysql]# mysql -uroot -p

Enter password: <输入新设的密码newpassword> 

 

rpm安装默认目录:
数据文件:/var/lib/mysql/
配置文件模板:/usr/share/mysql
mysql客户端工具目录:/usr/bin
日志目录:/var/log/

------------------------------------------------------------------------------------------------------

18.1.24

在Centos7安装mysql的时候遇到了一个问题

 file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.6.36-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.52-1.el7.x86_64
file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.6.36-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.52-1.el7.x86_64
file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.6.36-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.52-1.el7.x86_64
file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.6.36-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.52-1.el7.x86_64
file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.6.36-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.52-1.el7.x86_64
file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.6.36-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.52-1.el7.x86_64

这个问题是因为安装mysql的时候没有卸载自带的mysql,尝试用文章前的方法但是没有用,百度了一个类似的错误,发现要卸载mysql-libs这个东西,

执行

yum remove mysql-libs 

然后再安装mysql就行了。
 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值