共计 6828 个字符,预计需要花费 18 分钟才能阅读完成。
Linux 下安装 MySQL 5.7.11
拷贝 mysql5.7 安装包
bash-4.1# cp /mnt/hgfs/Downloads/mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar /home
解压安装包
bash-4.1# tar -xvf mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar
mysql-community-embedded-5.7.11-1.el6.x86_64.rpm
mysql-community-common-5.7.11-1.el6.x86_64.rpm
mysql-community-test-5.7.11-1.el6.x86_64.rpm
mysql-community-client-5.7.11-1.el6.x86_64.rpm
mysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpm
mysql-community-server-5.7.11-1.el6.x86_64.rpm
mysql-community-devel-5.7.11-1.el6.x86_64.rpm
mysql-community-libs-5.7.11-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.11-1.el6.x86_64.rpm
检查系统已经安装的 mysql 包
bash-4.1# rpm -qa | grep mysql
rsyslog-mysql-4.6.2-2.el6.x86_64
php-mysql-5.3.2-6.el6.x86_64
mysql-server-5.1.47-4.el6.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
mysql-5.1.47-4.el6.x86_64
dovecot-mysql-2.0-0.10.beta6.20100630.el6.x86_64
mysql-libs-5.1.47-4.el6.x86_64
mod_auth_mysql-3.0.0-11.el6.x86_64
qt-mysql-4.6.2-16.el6.x86_64
mysql-devel-5.1.47-4.el6.x86_64
删除原有 mysql 的安装包
bash-4.1# rpm -e rsyslog-mysql-4.6.2-2.el6.x86_64 --nodeps
bash-4.1# rpm -e php-mysql-5.3.2-6.el6.x86_64 --nodeps
bash-4.1# rpm -e mysql-server-5.1.47-4.el6.x86_64 --nodeps
bash-4.1# rpm -e mysql-connector-odbc-5.1.5r1144-7.el6.x86_64 --nodeps
bash-4.1# rpm -e mysql-5.1.47-4.el6.x86_64 --nodeps
bash-4.1# rpm -e dovecot-mysql-2.0-0.10.beta6.20100630.el6.x86_64 --nodeps
bash-4.1# rpm -e mysql-libs-5.1.47-4.el6.x86_64 --nodeps
bash-4.1# rpm -e mod_auth_mysql-3.0.0-11.el6.x86_64 --nodeps
bash-4.1# rpm -e qt-mysql-4.6.2-16.el6.x86_64 --nodeps
bash-4.1# rpm -e mysql-devel-5.1.47-4.el6.x86_64 --nodeps
安装 mysql5.7 的相关包,注意安装顺序,因为包之间有依赖。
bash-4.1# rpm -ivh mysql-community-common-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-common ########################################### [100%]
bash-4.1#
bash-4.1# rpm -ivh mysql-community-libs-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-libs-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-libs ########################################### [100%]
bash-4.1#
bash-4.1#
bash-4.1# rpm -ivh mysql-community-embedded-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-embedded-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-embedde########################################### [100%]
bash-4.1# rpm -ivh mysql-community-client-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-client ########################################### [100%]
bash-4.1#
bash-4.1#
bash-4.1# rpm -ivh mysql-community-server-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-server ########################################### [100%]
bash-4.1#
bash-4.1# rpm -ivh mysql-community-devel-5.7.11-1.el6.x86_64.rpm
warning: mysql-community-devel-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-devel ########################################### [100%]
bash-4.1# ll /var/lib/mysql
total 0
修改 mysql 的配置 my.cnf,关闭严格的密码设置,增加 validate_password=OFF 设置
bash-4.1# vi /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# 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
#
# 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
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
validate_password=OFF
启动 mysql 服务
bash-4.1#
/etc/rc.d/init.d/mysqld start
Initializing MySQL database: [OK]
Installing validate password plugin: [OK]
Starting mysqld: [OK]
有时 validate_password=OFF 会不生效,需要重启一下 mysql 服务
/etc/rc.d/init.d/mysqld restart
在 mysql 的安装目录下会产生相关文件
bash-4.1# ll /var/lib/mysql
total 122948
-rw-r-----. 1 mysql mysql 56 Mar 31 17:04 auto.cnf
-rw-------. 1 mysql mysql 1675 Mar 31 17:04 ca-key.pem
-rw-r--r--. 1 mysql mysql 1074 Mar 31 17:04 ca.pem
-rw-r--r--. 1 mysql mysql 1078 Mar 31 17:04 client-cert.pem
-rw-------. 1 mysql mysql 1675 Mar 31 17:04 client-key.pem
-rw-r-----. 1 mysql mysql 346 Mar 31 17:04 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Mar 31 17:04 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Mar 31 17:04 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Mar 31 17:04 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912 Mar 31 17:04 ibtmp1
drwxr-x---. 2 mysql mysql 4096 Mar 31 17:04 mysql
-rw-rw----. 1 root root 6 Mar 31 17:04 mysqld_safe.pid
srwxrwxrwx. 1 mysql mysql 0 Mar 31 17:04 mysql.sock
-rw-------. 1 mysql mysql 6 Mar 31 17:04 mysql.sock.lock
drwxr-x---. 2 mysql mysql 4096 Mar 31 17:04 performance_schema
-rw-------. 1 mysql mysql 1679 Mar 31 17:04 private_key.pem
-rw-r--r--. 1 mysql mysql 451 Mar 31 17:04 public_key.pem
-rw-r--r--. 1 mysql mysql 1078 Mar 31 17:04 server-cert.pem
-rw-------. 1 mysql mysql 1675 Mar 31 17:04 server-key.pem
drwxr-x---. 2 mysql mysql 12288 Mar 31 17:04 sys
修改 mysql 的 root 用户的登陆密码
bash-4.1# mysql -u -root -p
Enter password:
ERROR 1045 (28000): Access denied for user '-root'@'localhost' (using password: NO)
bash-4.1#
bash-4.1# /etc/rc.d/init.d/mysqld stop
Stopping mysqld: [OK]
bash-4.1# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 10436
bash-4.1# 2016-03-31T09:06:56.496531Z mysqld_safe Logging to '/var/log/mysqld.log'.
2016-03-31T09:06:56.613061Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
bash-4.1# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user SET authentication_string=PASSWORD('zcxc123') where USER='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> quit
Bye
bash-4.1# etc/rc.d/init.d/mysqld restart
进入 mysql 后,第一件事件就是要你改默认密码,由于已经关闭 v
alidate_password 功能,因此可以设置简单的密码
[root@c12 mysql57]# ./bin/mysql -u root -p
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password = password('zcxc1234')
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2016-11/136832.htm
正文完
星哥玩云-微信公众号