CentOS7 安装 mysql5.7 +

 

安装目录概览

 

Directory Contents of Directory
/usr/bin Client programs and scripts
/usr/sbin The mysqld server
/var/lib/mysql Log files, databases
/var/lib/mysql-files Value of secure_file_priv
/usr/share/info MySQL manual in Info format
/usr/share/man Unix manual pages
/usr/include/mysql Include (header) files
/usr/lib/mysql Libraries
/usr/share/mysql Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation
/usr/share/sql-bench Benchmarks

一.快速模式

1.下载安装包,

链接:https://pan.baidu.com/s/1wcIeJ3oxkwTsX0R3E67X0w  密码:2ulp

一共五个文件!!!

-rw-r--r-- 1 root root  45109364 10月 11 00:06 mysql-community-client-5.7.28-1.el7.x86_64.rpm
-rw-r--r-- 1 root root    318768 10月 11 00:06 mysql-community-common-5.7.28-1.el7.x86_64.rpm
-rw-r--r-- 1 root root   4374364 10月 11 00:07 mysql-community-libs-5.7.28-1.el7.x86_64.rpm
-rw-r--r-- 1 root root   1353312 10月 11 00:07 mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 208694824 10月 11 00:07 mysql-community-server-5.7.28-1.el7.x86_64.rpm

 

2.安装

rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm --force --nodeps

 

3.配置&安装请参考下面的配置.

 

二.常规 yum 安装方式

1.添加 mysql 的 yum 源

 

 sudo rpm -Uvh https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm

https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm

 

这个地址是官网上的, 可以去官网下载.

地址: https://dev.mysql.com/downloads/repo/yum/

 

2.查看 mysql 组件

 yum repolist all | grep mysql

 

[root@h30 software]# yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community      禁用
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - So 禁用
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community      禁用
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - So 禁用
mysql-cluster-8.0-community/x86_64 MySQL Cluster 8.0 Community      禁用
mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - So 禁用
mysql-connectors-community/x86_64  MySQL Connectors Community       启用:    131
mysql-connectors-community-source  MySQL Connectors Community - Sou 禁用
mysql-tools-community/x86_64       MySQL Tools Community            启用:    100
mysql-tools-community-source       MySQL Tools Community - Source   禁用
mysql-tools-preview/x86_64         MySQL Tools Preview              禁用
mysql-tools-preview-source         MySQL Tools Preview - Source     禁用
mysql55-community/x86_64           MySQL 5.5 Community Server       禁用
mysql55-community-source           MySQL 5.5 Community Server - Sou 禁用
mysql56-community/x86_64           MySQL 5.6 Community Server       禁用
mysql56-community-source           MySQL 5.6 Community Server - Sou 禁用
mysql57-community/x86_64           MySQL 5.7 Community Server       启用:    384
mysql57-community-source           MySQL 5.7 Community Server - Sou 禁用
mysql80-community/x86_64           MySQL 8.0 Community Server       禁用
mysql80-community-source           MySQL 8.0 Community Server - Sou 禁用

3.开启/禁用 mysql 版本

 

在这里要看你需要安装的 mysql 的对应版本是否是在开启的状态, 不然会装成别的版本哦

 

# 关闭 8.0 版本

shell> sudo yum-config-manager --disable mysql80-community

# 开启 5.7 版本

shell> sudo yum-config-manager --enable mysql57-community

 

4.安装

yum install -y mysql-server

 

5.配置

 

vi /etc/my.cnf

自行更改数据配置目录等等....

basedir = /opt/modules/mysql
datadir = /opt/modules/mysql/data/
port = 3306
# server_id = .....
socket =  /tmp/mysql.sock

# 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.


innodb_buffer_pool_size=6G

join_buffer_size = 256M
sort_buffer_size = 8M
key_buffer_size = 8M

max_allowed_packet = 100M

 

 

6.启动/关闭

 

sudo systemctl start mysqld.service

sudo systemctl status mysqld.service

 

查看端口号:  ss -lntp | grep 3306  

守护进程: chkconfig --level 35 mysqld on    

 

7.登录

 

查看密码:

sudo grep 'temporary password' /var/log/mysqld.log

 

登录

mysql -uroot -p

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
 

修改密码策略

如果你修改的密码没有验证通过,可以执行下面两句修改密码策略

set global validate_password_policy=0;

set global validate_password_length=0;

 

8.开启远程连接

mysql无法链接。。   !!!! 
	java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
		1、mysql -u root -poperation123
		2、use mysql;
		3、select user,host from user;
		4、select user,host from user where host='%';
			如果数据为空则:update user set host='%' where host = '127.0.0.1';  (切记 root用户不要清空啊!!!!   )
			如果数据为空则:update user set host='%' where user = 'root';  (切记 root用户不要清空啊!!!!   )
		5、select user,host from user where host!='%';
		6、delete from user where host!='%'; 
		7、select user,host from user;
		
		
		
		8.Ctrl-C -- exit!
		9、su - root
		10、service mysqld restart
		

 

 

9.其他

YUM 方式下载 RPM 包

 yum install --downloadonly --downloaddir=/opt/software mysql-server

 

卸载 rpm 包 , 不清除依赖

 

rpm -e --nodeps mysql-community-libs-compat-5.7.28-1.el7.x86_64
rpm -e --nodeps mysql-community-server-5.7.28-1.el7.x86_64
rpm -e --nodeps mysql-community-libs-5.7.28-1.el7.x86_64
rpm -e --nodeps mysql-community-client-5.7.28-1.el7.x86_64
rpm -e --nodeps mysql-community-common-5.7.28-1.el7.x86_64

 

 

查看所有 rpm 安装的软件

rpm -qa | grep mysql

 

 

7.2参考官方地址:

https://dev.mysql.com/doc/refman/5.7/en/getting-mysql.html

https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

 

 

 

发布了315 篇原创文章 · 获赞 811 · 访问量 36万+
展开阅读全文

虚拟机centos7上装MySQL5.7.18出现的问题

04-21

运行:systemctl start mysqld 错误:Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details. mysqld.log中的提示: 2017-04-19T15:20:26.718566Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation. 2017-04-19T15:20:26.718643Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory. 2017-04-19T15:20:26.718655Z 0 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions 2017-04-19T15:20:26.718728Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2017-04-19T15:20:28.189585Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 2017-04-19T15:20:28.189678Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2017-04-19T15:20:28.189696Z 0 [ERROR] Failed to initialize plugins. 2017-04-19T15:20:28.189708Z 0 [ERROR] Aborting 2017-04-19T15:20:28.189763Z 0 [Note] Binlog end 2017-04-19T15:20:28.192297Z 0 [Note] Shutting down plugin 'CSV' 2017-04-19T15:20:28.194679Z 0 [Note] /usr/sbin/mysqld: Shutdown complete 2017-04-19T15:20:31.320424Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-04-19T15:20:31.323827Z 0 [Warning] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory. 2017-04-19T15:20:31.323949Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.18) starting as process 69981 ... 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 鲸 设计师: meimeiellie

分享到微信朋友圈

×

扫一扫,手机浏览