CentOS7.4 源码编译安装MySQL8.0.15

1.安装前清理工作

1.1.1 清理原有的mysql数据库
rpm -qa | grep mysql

查询mariadb

rpm -qa | grep mariadb

通过 rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps 命令装卸 mariadb

2.下载并安装MySQL官方的 Yum Repository

[root@iZ8vb8m76py2k3md3xuj6jZ ~]# wget -i -c  https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

使用上面的命令就直接下载了安装用的Yum Repository,大概25KB的样子,然后就可以直接yum安装了。

[root@iZ8vb8m76py2k3md3xuj6jZ ~]# yum -y install mysql80-community-release-el7-1.noarch.rpm

之后就开始安装MySQL服务器。

[root@iZ8vb8m76py2k3md3xuj6jZ ~]# yum -y install mysql-community-server

这步可能会花些时间,安装完成后显示

1 mysql-community-libs-compat-8.0.11-1.el7.x86_64
2 mysql-community-server-8.0.11-1.el7.x86_64
3 mysql-community-common-8.0.11-1.el7.x86_64
4 mysql-community-libs-8.0.11-1.el7.x86_64
5 mysql-community-client-8.0.11-1.el7.x86_64

3.MySQL数据库设置

首先启动MySQL

[root@iZ8vb8m76py2k3md3xuj6jZ ~]# systemctl start  mysqld.service

查看MySQL运行状态,运行状态如图:

[root@iZ8vb8m76py2k3md3xuj6jZ ~]# systemctl status mysqld.service

此时MySQL已经开始正常运行,不过要想进入MySQL还得先找出此时root用户的密码,通过如下命令可以在日志文件中找出密码:

[root@iZ8vb8m76py2k3md3xuj6jZ ~]# grep "password" /var/log/mysqld.log

如下命令进入数据库:

[root@iZ8vb8m76py2k3md3xuj6jZ ~]# mysql -uroot -p

输入初始密码,此时不能做任何事情,因为MySQL默认必须修改密码之后才能操作数据库:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

MySQL完整的初始密码规则可以通过如下命令查看:

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password_check_user_name    | OFF   |
| validate_password_dictionary_file    |       |
| validate_password_length             | 4     |
| validate_password_mixed_case_count   | 1     |
| validate_password_number_count       | 1     |
| validate_password_policy             | LOW   |
| validate_password_special_char_count | 1     |
+--------------------------------------+-------+
7 rows in set (0.01 sec)

我的是已经修改过的,初始情况下第一个的值是ON,validate_password_length是8。可以通过如下命令修改:

mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;

另外一种密码加密模式(为了适应sqlyog 或者 navicat 登录 , 因为这些软件目前还没mysql最新版的密码加密方式,登录用的还是老模式):

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; 

设置Mysql可以远程访问

use mysql;
select host,user,authentication_string,plugin from user;
update user set host='%' where user='root';

4. 将mysql 服务加入开机启动项,并启动mysql进程

systemctl enable mysqld.service
systemctl start mysqld.service

常用mysql服务命令:

登录mysql
mysql -u username -p
 
退出mysql 
quit
 
启动mysql
systemctl start mysqld.service
 
结束
systemctl stop mysqld.service
 
重启
systemctl restart mysqld.service
 
开机自启
systemctl enable mysqld.service
 
查看mysql版本
select version();

转载于:https://my.oschina.net/jinhong/blog/3023443

你可能感兴趣的:(数据库,运维)