CentOS 7 版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了。
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。
1.检查系统是否已经安装过mysql
rpm -qa|grep mariadb
如果查询到结果,证明已经安装过,必须先卸载
2.卸载mariadb
rpm -e --nodeps mariadb-libs
3. 下载mysql
4.通过ftp工具传到服务器
5.解压
tar -xvf mysql-8.0.25-1.el7.x86_64.rpm-bundle.tar
会有如下文件
mysql-community-client-8.0.25-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
mysql-community-common-8.0.25-1.el7.x86_64.rpm
mysql-community-devel-8.0.25-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.25-1.el7.x86_64.rpm
mysql-community-libs-8.0.25-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.25-1.el7.x86_64.rpm
mysql-community-server-8.0.25-1.el7.x86_64.rpm
mysql-community-test-8.0.25-1.el7.x86_64.rpm
6.执行
rpm -ivh mysql-community-common-8.*********.rpm
rpm -ivh mysql-community-libs-8.*********.x86_64.rpm
rpm -ivh mysql-community-client-8.*********.x86_64.rpm
rpm -ivh mysql-community-server-8.*********.x86_64.rpm
中途可能会报如下错误
warning: mysql-community-libs-8.0.25-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-client-plugins = 8.0.25-1.el7 is needed by mysql-community-libs-8.0.25-1.el7.x86_64
mariadb-libs is obsoleted by mysql-community-libs-8.0.25-1.el7.x86_64
mysql-community-client-plugins = 8.0.25-1.el7 is needed by mysql-community-libs-8.0.25-1.el7.x86_64 这个问题是要求 先安装mysql-community-client-plugins
mariadb-libs is obsoleted by mysql-community-libs-8.0.25-1.el7.x86_64 这个问题是没有删除mariadb的依赖包 可执行 yum remove mysql-libs解决
阿里云安装mysql-community-server-8.0.25-1.el7.x86_64.rpm报错
error: Failed dependencies:
libaio.so.1()(64bit) is needed by MySQL-server-5.5.25a-1.rhel5.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.5.25a-1.rhel5.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.5.25a-1.rhel5.x86_64
执行 yum install libaio 解决
mysql 配置文件路径
/etc/my.conf
7.查看mysql的服务
[root@ssss software]# systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
上面 Active 显示 服务未启动
8.启动服务
[root@ssss software]# systemctl start mysqld.service
[root@ssss software]#
[root@ssss software]# systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: active (running) since Mon 2018-03-26 09:26:04 CST; 2s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 2113 ExecStart=/usr/sbin/mysqld --daemonize --pid-
file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 2034 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 2116 (mysqld)
CGroup: /system.slice/mysqld.service
上面 Active 显示 服务已启动
9.mysql服务启动成功,首先使用临时的密码进行登录,查看临时密码
[root@ssss software]# grep "password" /var/log/mysqld.log
1 [Note] A temporary password is generated for root@localhost: password
10.使用临时密码登录,然后修改root的密码
[root@ssss software]# mysql -uroot -ppassword
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql>
11.修改root密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'ssssss';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
MySQL :: MySQL 8.0 Reference Manual :: 8.4.3.2 Password Validation Options and Variables
密码太简单
上述报错的原因:其实与validate_password_policy的值有关。
validate_password_policy有以下取值:
默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符
mysql> SHOW VARIABLES LIKE 'validate_password.%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1 |
+--------------------------------------+--------+
set global validate_password.policy=LOW 可通过这个命令修改密码级别等
最后开放防火墙端口 并重启mysql
参考文章
https://www.cnblogs.com/y-c-m520/p/14061043.html
https://www.cnblogs.com/lzc55555/p/11832562.html
https://www.cnblogs.com/yss818824/p/12349719.html
https://www.cnblogs.com/starof/p/4680083.html
MySQL :: MySQL 8.0 Reference Manual :: 8.4.3.2 Password Validation Options and Variables