赞
踩
操作系统:CentOS Linux release 7.3.1611 (Core)
数据库系统: MySQL 5.7.19
IP: 192.168.230.134
直接使用yum安装mysql包,发现无法正常安装,提示已经安装了mariadb-server数据库,这是因为我的操作系统在安装的时候自动安装了这个数据库,需要先将此数据库卸载
[root@localhost yum.repos.d]# yum install mysql-community-server.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* epel: mirrors.ustc.edu.cn
* extras: mirrors.163.com
* updates: centos.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
---> Package mysql-community-server.x86_64 0:5.7.19-1.el7 will be obsoleting
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.19-1.el7 for package: mysql-community-server-5.7.19-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.19-1.el7.x86_64
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.52-1.el7 will be obsoleted
---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
---> Package mysql-community-client.x86_64 0:5.7.19-1.el7 will be obsoleting
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.19-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.19-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: perl-DBD-MySQL-4.023-5.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:qt-mysql-4.8.5-13.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: perl-DBD-MySQL-4.023-5.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 1:qt-mysql-4.8.5-13.el7.x86_64
---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.19-1.el7 will be obsoleting
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
---> Package mysql-community-libs-compat.x86_64 0:5.7.19-1.el7 will be obsoleting
--> Finished Dependency Resolution
Error: Package: akonadi-mysql-1.9.2-4.el7.x86_64 (@anaconda)
Requires: mariadb-server
Removing: 1:mariadb-server-5.5.52-1.el7.x86_64 (@anaconda)
mariadb-server = 1:5.5.52-1.el7
Obsoleted By: mysql-community-server-5.7.19-1.el7.x86_64 (mysql57-community)
Not found
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
使用yum 命令先卸载掉mariadb
[root@localhost yum.repos.d]# yum -y remove mariadb-libs.x86_64
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be erased
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: perl-DBD-MySQL-4.023-5.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:qt-mysql-4.8.5-13.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: perl-DBD-MySQL-4.023-5.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 1:qt-mysql-4.8.5-13.el7.x86_64
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.52-1.el7 for package: 1:mariadb-server-5.5.52-1.el7.x86_64
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.52-1.el7 for package: 1:mariadb-5.5.52-1.el7.x86_64
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.52-1.el7 will be erased
---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be erased
--> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
---> Package perl-DBD-MySQL.x86_64 0:4.023-5.el7 will be erased
---> Package postfix.x86_64 2:2.10.1-6.el7 will be erased
---> Package qt-mysql.x86_64 1:4.8.5-13.el7 will be erased
--> Running transaction check
---> Package akonadi-mysql.x86_64 0:1.9.2-4.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================
Package Arch Version Repository Size
========================================================================================
Removing:
mariadb-libs x86_64 1:5.5.52-1.el7 @anaconda 4.4 M
Removing for dependencies:
akonadi-mysql x86_64 1.9.2-4.el7 @anaconda 9.6 k
mariadb x86_64 1:5.5.52-1.el7 @anaconda 48 M
mariadb-server x86_64 1:5.5.52-1.el7 @anaconda 56 M
perl-DBD-MySQL x86_64 4.023-5.el7 @anaconda 323 k
postfix x86_64 2:2.10.1-6.el7 @anaconda 12 M
qt-mysql x86_64 1:4.8.5-13.el7 @anaconda 74 k
Transaction Summary
========================================================================================
Remove 1 Package (+6 Dependent packages)
Installed size: 121 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : akonadi-mysql-1.9.2-4.el7.x86_64 1/7
Erasing : 1:mariadb-server-5.5.52-1.el7.x86_64 2/7
Erasing : 1:mariadb-5.5.52-1.el7.x86_64 3/7
Erasing : perl-DBD-MySQL-4.023-5.el7.x86_64 4/7
Erasing : 1:qt-mysql-4.8.5-13.el7.x86_64 5/7
Erasing : 2:postfix-2.10.1-6.el7.x86_64 6/7
Erasing : 1:mariadb-libs-5.5.52-1.el7.x86_64 7/7
Verifying : 1:mariadb-5.5.52-1.el7.x86_64 1/7
Verifying : 1:mariadb-server-5.5.52-1.el7.x86_64 2/7
Verifying : akonadi-mysql-1.9.2-4.el7.x86_64 3/7
Verifying : 1:mariadb-libs-5.5.52-1.el7.x86_64 4/7
Verifying : 1:qt-mysql-4.8.5-13.el7.x86_64 5/7
Verifying : 2:postfix-2.10.1-6.el7.x86_64 6/7
Verifying : perl-DBD-MySQL-4.023-5.el7.x86_64 7/7
Removed:
mariadb-libs.x86_64 1:5.5.52-1.el7
Dependency Removed:
akonadi-mysql.x86_64 0:1.9.2-4.el7 mariadb.x86_64 1:5.5.52-1.el7
mariadb-server.x86_64 1:5.5.52-1.el7 perl-DBD-MySQL.x86_64 0:4.023-5.el7
postfix.x86_64 2:2.10.1-6.el7 qt-mysql.x86_64 1:4.8.5-13.el7
Complete!
再执行MySQL安装,即可正常安装
[root@localhost yum.repos.d]# yum install mysql-community-server.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* epel: mirrors.ustc.edu.cn
* extras: mirrors.163.com
* updates: centos.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.19-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.19-1.el7 for package: mysql-community-server-5.7.19-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.19-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.19-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.19-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.19-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.19-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
mysql-community-server x86_64 5.7.19-1.el7 mysql57-community 164 M
Installing for dependencies:
mysql-community-client x86_64 5.7.19-1.el7 mysql57-community 24 M
mysql-community-common x86_64 5.7.19-1.el7 mysql57-community 272 k
mysql-community-libs x86_64 5.7.19-1.el7 mysql57-community 2.1 M
Transaction Summary
========================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 190 M
Installed size: 856 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.19-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.7.19-1.el7.x86_64.rpm is not installed
(1/4): mysql-community-common-5.7.19-1.el7.x86_64.rpm | 272 kB 00:00:03
(2/4): mysql-community-libs-5.7.19-1.el7.x86_64.rpm | 2.1 MB 00:00:06
(3/4): mysql-community-client-5.7.19-1.el7.x86_64.rpm | 24 MB 00:06:55
(4/4): mysql-community-server-5.7.19-1.el7.x86_64.rpm | 164 MB 00:31:35
----------------------------------------------------------------------------------------
Total 102 kB/s | 190 MB 31:44
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-11.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
Installing : mysql-community-common-5.7.19-1.el7.x86_64 1/4
Installing : mysql-community-libs-5.7.19-1.el7.x86_64 2/4
Installing : mysql-community-client-5.7.19-1.el7.x86_64 3/4
Installing : mysql-community-server-5.7.19-1.el7.x86_64 4/4
Verifying : mysql-community-libs-5.7.19-1.el7.x86_64 1/4
Verifying : mysql-community-common-5.7.19-1.el7.x86_64 2/4
Verifying : mysql-community-client-5.7.19-1.el7.x86_64 3/4
Verifying : mysql-community-server-5.7.19-1.el7.x86_64 4/4
Installed:
mysql-community-server.x86_64 0:5.7.19-1.el7
Dependency Installed:
mysql-community-client.x86_64 0:5.7.19-1.el7
mysql-community-common.x86_64 0:5.7.19-1.el7
mysql-community-libs.x86_64 0:5.7.19-1.el7
Complete!
安装拓展包
[root@localhost yum.repos.d]# yum install mysql-community-devel.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* epel: mirrors.ustc.edu.cn
* extras: mirrors.163.com
* updates: centos.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-devel.x86_64 0:5.7.19-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
mysql-community-devel x86_64 5.7.19-1.el7 mysql57-community 3.6 M
Transaction Summary
========================================================================================
Install 1 Package
Total download size: 3.6 M
Installed size: 21 M
Is this ok [y/d/N]: y
Downloading packages:
mysql-community-devel-5.7.19-1.el7.x86_64.rpm | 3.6 MB 00:00:11
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-devel-5.7.19-1.el7.x86_64 1/1
Verifying : mysql-community-devel-5.7.19-1.el7.x86_64 1/1
Installed:
mysql-community-devel.x86_64 0:5.7.19-1.el7
Complete!
启动mysqld服务,并设为开机自动启动
[root@localhost yum.repos.d]# systemctl start mysqld.service
[root@localhost yum.repos.d]# systemctl enable mysqld.service
这时想进入mysql的时候碰到问题
[root@localhost yum.repos.d]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost yum.repos.d]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost yum.repos.d]# mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
经过查文档发现这是由于没有在user表中写入用户信息,只能使用不启动授权表的启动方式:
修改my.cnf配置
[root@localhost etc]# vim /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
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
skip-grant-tables
重启MySQL服务
[root@localhost etc]# systemctl restart mysqld
进入数据库,修改user表
[root@localhost etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.19 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
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 password=password("oracle") where user="root";
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
此时居然发现字段无法修改,经查,这是由于5.7版本user表的字段名做了变更
查询user表的字段:
mysql> mysql> select * from user\G
*************************** 1. row ***************************
Host: localhost
User: root
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: Y
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Create_tablespace_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string: *689264C0FE373E6ABF78817EDA7C01C7F9877BA1
password_expired: Y
password_last_changed: 2017-09-12 22:53:42
password_lifetime: NULL
account_locked: N
*************************** 2. row ***************************
Host: localhost
User: mysql.session
Select_priv: N
Insert_priv: N
Update_priv: N
Delete_priv: N
Create_priv: N
Drop_priv: N
Reload_priv: N
Shutdown_priv: N
Process_priv: N
File_priv: N
Grant_priv: N
References_priv: N
Index_priv: N
Alter_priv: N
Show_db_priv: N
Super_priv: Y
Create_tmp_table_priv: N
Lock_tables_priv: N
Execute_priv: N
Repl_slave_priv: N
Repl_client_priv: N
Create_view_priv: N
Show_view_priv: N
Create_routine_priv: N
Alter_routine_priv: N
Create_user_priv: N
Event_priv: N
Trigger_priv: N
Create_tablespace_priv: N
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string: *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE
password_expired: N
password_last_changed: 2017-09-12 22:53:42
password_lifetime: NULL
account_locked: Y
*************************** 3. row ***************************
Host: localhost
User: mysql.sys
Select_priv: N
Insert_priv: N
Update_priv: N
Delete_priv: N
Create_priv: N
Drop_priv: N
Reload_priv: N
Shutdown_priv: N
Process_priv: N
File_priv: N
Grant_priv: N
References_priv: N
Index_priv: N
Alter_priv: N
Show_db_priv: N
Super_priv: N
Create_tmp_table_priv: N
Lock_tables_priv: N
Execute_priv: N
Repl_slave_priv: N
Repl_client_priv: N
Create_view_priv: N
Show_view_priv: N
Create_routine_priv: N
Alter_routine_priv: N
Create_user_priv: N
Event_priv: N
Trigger_priv: N
Create_tablespace_priv: N
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string: *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE
password_expired: N
password_last_changed: 2017-09-12 22:53:42
password_lifetime: NULL
account_locked: Y
3 rows in set (0.00 sec)
可知道password字段已经变成了authentication_string字段,对我们的代码稍作修改即可:
mysql> update mysql.user set authentication_string=password('oracle') where user='root' ;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
刷新系统权限并退出
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
改回my.cnf配置并重启服务
[root@localhost etc]# vim my.cnf
[root@localhost etc]# systemctl restart mysqld
这是再次进入MySQL发现还是有问题
[root@localhost etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.19
Copyright (c) 2000, 2017, 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> show databases
-> ;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password=password('oracle');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
查文档后发现原来MySQL 5.7在安装后会自动启动密码限制进程,密码必须有一定复杂度,即包含大小写和数字,如’MyNewPass4!’,我给出的密码oracle显然不符合标准
由于只是测试环境,我不希望用复杂的密码,所以只能去修改密码限制了:
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_mixed_case_count=2;
Query OK, 0 rows affected (0.00 sec)
这时再去修改密码即可
mysql> alter user 'root'@'localhost' identified by 'oracle';
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
此时MySQL数据库正式配置完成
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。