发表于: 2018-03-28 18:57:36

1 619


今天完成的事情:


1.linux下mysql的安装

2.mysql的远程连接部署



睡了一觉,满血复活。


1.按照帆哥给的地址重装(蓝色是命令,其它请忽略):


[root@VM_129_126_centos ~]# wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
--2018-03-28 09:29:47-- http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.56.25.233
Connecting to repo.mysql.com (repo.mysql.com)|23.56.25.233|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9116 (8.9K) [application/x-redhat-package-manager]
Saving to: ‘mysql57-community-release-el7-8.noarch.rpm’

100%[==========================================================================>] 9,116 --.-K/s in 0s

2018-03-28 09:29:48 (154 MB/s) - ‘mysql57-community-release-el7-8.noarch.rpm’ saved [9116/9116]

[root@VM_129_126_centos ~]# rpm -ivh mysql57-community-release-el7-8.noarch.rpm
warning: mysql57-community-release-el7-8.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql57-community-release-el7-8 ################################# [100%]
[root@VM_129_126_centos ~]# ls .etc/yum.repos.d/
ls: cannot access .etc/yum.repos.d/: No such file or directory
[root@VM_129_126_centos ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Sources.repo mysql-community.repo
CentOS-CR.repo CentOS-Epel.repo CentOS-Media.repo CentOS-Vault.repo mysql-community-source.repo
[root@VM_129_126_centos ~]# yum install mysql-server
Loaded plugins: fastestmirror, langpacks
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql57-community | 2.5 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/10): epel/7/x86_64/group_gz | 266 kB 00:00:00
(2/10): extras/7/x86_64/primary_db | 184 kB 00:00:00
(3/10): epel/7/x86_64/updateinfo | 904 kB 00:00:00
(4/10): mysql-connectors-community/x86_64/primary_db | 18 kB 00:00:00
(5/10): os/7/x86_64/group_gz | 156 kB 00:00:00
(6/10): mysql57-community/x86_64/primary_db | 134 kB 00:00:00
(7/10): epel/7/x86_64/primary_db | 6.3 MB 00:00:00
(8/10): os/7/x86_64/primary_db | 5.7 MB 00:00:00
(9/10): updates/7/x86_64/primary_db | 6.9 MB 00:00:00
(10/10): mysql-tools-community/x86_64/primary_db | 39 kB 00:00:01
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.21-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.21-1.el7 for package: mysql-community-server-5.7.21-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.21-1.el7.x86_64
--> Processing Dependency: libnuma.so.1(libnuma_1.2)(64bit) for package: mysql-community-server-5.7.21-1.el7.x86_64
--> Processing Dependency: libnuma.so.1(libnuma_1.1)(64bit) for package: mysql-community-server-5.7.21-1.el7.x86_64
--> Processing Dependency: libnuma.so.1()(64bit) for package: mysql-community-server-5.7.21-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.21-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.21-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.21-1.el7 will be installed
---> Package numactl-libs.x86_64 0:2.0.9-6.el7_2 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.21-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.21-1.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================
Package Arch Version Repository Size
======================================================================================================================
Installing:
mysql-community-libs x86_64 5.7.21-1.el7 mysql57-community 2.1 M
replacing mariadb-libs.x86_64 1:5.5.56-2.el7
mysql-community-libs-compat x86_64 5.7.21-1.el7 mysql57-community 2.0 M
replacing mariadb-libs.x86_64 1:5.5.56-2.el7
mysql-community-server x86_64 5.7.21-1.el7 mysql57-community 164 M
Installing for dependencies:
mysql-community-client x86_64 5.7.21-1.el7 mysql57-community 24 M
mysql-community-common x86_64 5.7.21-1.el7 mysql57-community 272 k
numactl-libs x86_64 2.0.9-6.el7_2 os 29 k

Transaction Summary
======================================================================================================================
Install 3 Packages (+3 Dependent packages)

Total download size: 192 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.21-1.el7.x86_64.rpm: Header V3DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.7.21-1.el7.x86_64.rpm is not installed
(1/6): mysql-community-common-5.7.21-1.el7.x86_64.rpm | 272 kB 00:00:00
(2/6): mysql-community-libs-5.7.21-1.el7.x86_64.rpm | 2.1 MB 00:00:00
(3/6): mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm | 2.0 MB 00:00:00
(4/6): numactl-libs-2.0.9-6.el7_2.x86_64.rpm | 29 kB 00:00:00
(5/6): mysql-community-client-5.7.21-1.el7.x86_64.rpm | 24 MB 00:00:49
(6/6): mysql-community-server-5.7.21-1.el7.x86_64.rpm | 164 MB 00:06:11
----------------------------------------------------------------------------------------------------------------------
Total 529 kB/s | 192 MB 00:06:12
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql57-community-release-el7-8.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : mysql-community-common-5.7.21-1.el7.x86_64 1/7
Installing : mysql-community-libs-5.7.21-1.el7.x86_64 2/7
Installing : mysql-community-client-5.7.21-1.el7.x86_64 3/7
Installing : numactl-libs-2.0.9-6.el7_2.x86_64 4/7
Installing : mysql-community-server-5.7.21-1.el7.x86_64 5/7
Installing : mysql-community-libs-compat-5.7.21-1.el7.x86_64 6/7
Erasing : 1:mariadb-libs-5.5.56-2.el7.x86_64 7/7
Verifying : mysql-community-client-5.7.21-1.el7.x86_64 1/7
Verifying : mysql-community-libs-compat-5.7.21-1.el7.x86_64 2/7
Verifying : mysql-community-libs-5.7.21-1.el7.x86_64 3/7
Verifying : numactl-libs-2.0.9-6.el7_2.x86_64 4/7
Verifying : mysql-community-server-5.7.21-1.el7.x86_64 5/7
Verifying : mysql-community-common-5.7.21-1.el7.x86_64 6/7
Verifying : 1:mariadb-libs-5.5.56-2.el7.x86_64 7/7

Installed:
mysql-community-libs.x86_64 0:5.7.21-1.el7 mysql-community-libs-compat.x86_64 0:5.7.21-1.el7
mysql-community-server.x86_64 0:5.7.21-1.el7

Dependency Installed:
mysql-community-client.x86_64 0:5.7.21-1.el7 mysql-community-common.x86_64 0:5.7.21-1.el7
numactl-libs.x86_64 0:2.0.9-6.el7_2

Replaced:
mariadb-libs.x86_64 1:5.5.56-2.el7

Complete!
[root@VM_129_126_centos ~]# mysqld --initialize
[root@VM_129_126_centos ~]# mysqld --user=root



到这里就没反应了,一直到服务器自动断开连接

初始化的时候失败

查看log:


2018-03-28T02:09:46.800057Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2018-03-28T02:09:46.800106Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2018-03-28T02:09:47.800244Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2018-03-28T02:09:47.800295Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2018-03-28T02:09:48.800409Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2018-03-28T02:09:48.800447Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2018-03-28T02:09:48.800452Z 0 [Note] InnoDB: Unable to open the first data file
2018-03-28T02:09:48.800474Z 0 [ERROR] InnoDB: Operating system error number 11 in a file operation.
2018-03-28T02:09:48.800531Z 0 [ERROR] InnoDB: Error number 11 means 'Resource temporarily unavailable'
2018-03-28T02:09:48.800537Z 0 [Note] InnoDB: Some operating system error numbers are described at http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html
2018-03-28T02:09:48.800541Z 0 [ERROR] InnoDB: Cannot open datafile './ibdata1'
2018-03-28T02:09:48.800551Z 0 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2018-03-28T02:09:48.800558Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Cannot open a file
2018-03-28T02:09:49.401358Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2018-03-28T02:09:49.401393Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-03-28T02:09:49.401398Z 0 [ERROR] Failed to initialize builtin plugins.
2018-03-28T02:09:49.401401Z 0 [ERROR] Aborting

2018-03-28T02:09:49.401410Z 0 [Note] Binlog end
2018-03-28T02:09:49.401483Z 0 [Note] Shutting down plugin 'CSV'
2018-03-28T02:09:49.401985Z 0 [Note] mysqld: Shutdown complete

2018-03-28T02:10:51.306426Z 4 [Warning] IP address '58.218.213.174' could not be resolved: Name or service not known

日志提示说:

[错误]InnoDB:不能打开或创建系统表空间。如果您试图向系统表空间中添加新的数据文件,并且在这里失败了,那么您现在应该在my.cnf中编辑innodb_data_file_path,并删除在这次失败的尝试中创建的新ibdata文件。InnoDB只写满了0的文件,但是没有使用它们。但是要小心:不要删除包含您宝贵数据的旧数据文件!

[错误]InnoDB:插件初始化失败,错误无法打开文件。

[错误]插件“InnoDB”的init函数返回错误。

【错误】插件“InnoDB”注册为存储引擎失败。

[错误]未能初始化builtin插件。

2018 - 03 - 28 - t02:09:49.401401z 0(错误)流产


查看my.cnf(etc/my.cnf)

看到:

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

把/var/lib/mysql下文件删除

rm -rf /var/lib/mysql

再次运行 mysqld --user=root

提示

mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 2 - No such file or directory)
2018-03-28T02:53:46.148557Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-28T02:53:46.148684Z 0 [Warning] Can't create test file /var/lib/mysql/VM_129_126_centos.lower-test
2018-03-28T02:53:46.148725Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 16222 ...
2018-03-28T02:53:46.151506Z 0 [Warning] Can't create test file /var/lib/mysql/VM_129_126_centos.lower-test
2018-03-28T02:53:46.151518Z 0 [Warning] Can't create test file /var/lib/mysql/VM_129_126_centos.lower-test
2018-03-28T02:53:46.151577Z 0 [ERROR] failed to set datadir to /var/lib/mysql/
2018-03-28T02:53:46.151590Z 0 [ERROR] Aborting

2018-03-28T02:53:46.151647Z 0 [Note] Binlog end
2018-03-28T02:53:46.151806Z 0 [Note] mysqld: Shutdown complete


运行错了,再次执行初始化:

[root@VM_129_126_centos ~]# mysqld --initialize
[root@VM_129_126_centos ~]# mysqld --user=root
[root@VM_129_126_centos ~]#

没有报错,但是没有初始化密码


查看日志:

/var/log/mysqld.log

找到两个个初始化密码,N75qjFoa%Yax、SlJ>Nlw(s9/j, 使用最后一次给出的密码:



如果mysqladmin 命令错误:

-bash: mysqldadmin: command not found

修改(添加到/usr/bin):

ln -s /usr/local/mysql/bin/mysql /usr/bin
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin


更改密码的时候遇到


ls -la /usr/local/mysql/data

使用find命令找不到mysql.sock,于是查找my.cnf配置文件:

找到了,打开配置目录


但是目录里没有mysql.sock,也找不到mysqld.sock文件

尝试杀死进程重启

使用隐式默认值的时间戳(警告)时间戳。请使用- it_defaults_for_timestamp服务器选项(更多细节请参阅文档)。

开始的过程,如过程24533……

(错误)致命错误:请阅读手册的“安全”部分,找出如何以root身份运行mysqld !

2018 - 03 - 28 - t06:48:49.532001z 0(错误)流产

2018-03-28 t06:48:49.532017z0[注释]Binlog end。

[注]mysqld:关闭完成



尝试重新初始化:


[root@VM_129_126_centos ~]# rm -rf /var/lib/mysql

[root@VM_129_126_centos ~]# mysqld --initialize
[root@VM_129_126_centos ~]# mysqld --user=root

依然没有mysql.sock


再次初始化,使用mysql用户

[root@VM_129_126_centos ~]# rm -rf /var/lib/mysql

[root@VM_129_126_centos ~]# mysqld --initialize
[root@VM_129_126_centos ~]# mysqld --user=mysql


报错:

mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13 - Permission denied)
2018-03-28T07:11:57.044532Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-28T07:11:57.046234Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 27168 ...
2018-03-28T07:11:57.048110Z 0 [ERROR] failed to set datadir to /var/lib/mysql/
2018-03-28T07:11:57.048127Z 0 [ERROR] Aborting

2018-03-28T07:11:57.048137Z 0 [Note] Binlog end
2018-03-28T07:11:57.048368Z 0 [Note] mysqld: Shutdown complete


尝试更改密码提示没有权限

重启也没有权限

更改文件目录权限后还是提示没有权限


重装了系统。

又重复了一遍。

又是到mysqld --user=root时间太久,系统自动断开连接

这次没有看其它的,看了日志,已经生成了密码。

然后查看数据库文件夹:

这次有mysql.sock文件了,赶紧拷贝一个。


然后尝试更改密码,竟然可以更改,之前输入密码直接提示ERROR。

登录:

成功。


不知道怎么回事主机总线控制驱动装不上了,电脑外设都没反应了。

用了远程连接,醉了,自己家的电脑还要用远程才能上。


2.修改mysql远程访问

mysql> use mysql;

select * from user;

看到root用户

修改

UPDATE user SET Host = '%' WHERE User= 'root' LIMIT 1;

刷新系统权限表(user)让它生效;

flush privileges;



远程访问:

一直拒绝……

使用cmd:

Lost connection to MySQL server at 'waiting for initial communication packet', system error: 0

使用Navicat连接:

SSH Tunnel:Authentication failed


然后重新在服务器控制台上查看了下,修改了安全组,然后在本地cmd直接使用 mysql -h ip -u name -p pass连接:

可以连接上了!


然后就是一些数据库表的注入。



明天计划的事情:


重新写一遍任务一项目,这两天没有写,全被远程各种坑。


开始在远程上布置maven/跑程序


遇到的问题:

linux下mysql的安装,远程连接的问题

不知道的情况下比较费时间,通了就感觉很简单,不通就感觉很麻烦,只能找各种方向尝试


收获:


1.linux下的命令一遍遍熟悉

2.mysql在服务器上的配置  

3.远程连接服务器的问题(还是数据库)

4.下午听杨聪聪师兄的小课堂还是很有收获的:

bean的注入方式/属性




返回列表 返回列表
评论

    分享到