|
1、mkdir /opt/mysql
2、cd /opt/mysql
3、wget http://dev.mysql.com/get/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
4、tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
注意: centos7.6自带了类mysql数据库mariadb,会跟mysql冲突,所以如果要安装mysql,需要先确认是否系统安装了mariadb,如果安装了,需要先删除mariadb
5、rpm -qa|grep mari,查询mariadb相关安装包
查到两个包:
mariadb-libs-5.5.60-1.el7_5.x86_64
marisa-0.2.4-4.el7.x86_64
删除这两个包: rpm -e --nodeps mariadb-libs(也可以写全mariadb-libs-5.5.60-1.el7_5.x86_64)
rpm -e --nodeps marisa
查询确认: rpm -qa | grep mari
6、安装mysql (在mysql目录下,执行,因为这些安装文件都在此目录下)
rpm -ivh mysql-community-common-5.7.26-l.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.26-l.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
7、启动mysql: systemctl start mysqld.service
8、设置mysql root用户密码:
mysql给root用户初始设置了一个随机密码,运行 grep "password" /var/log/mysqld.log 可查看到当前密码:
A temporary password is generated for root@localhost: #5ikcqeeqd
mysql -u root -p
输入刚才查到的密码 进入mysql
mysql>
mysql密码默认有复杂度要求,如果你想设置简单的密码,可以修改密码复杂度策略:
mysql>set global validate_password_policy=0; ( 0-2, 0是最低要求)
设置root密码:
mysql>set password for 'root'@'localhost' =password('mysql123');
使密码设置生效:
mysql>flush privileges;
验证密码:
mysql -u root -p 输入新密码进入mysql
mysql>show databases;
mysql>create database discuz;
mysql>use discuz;
mysql>create table myorder (id int,name varchar(32));
mysql>insert into myorder values(100,'dog');
mysql>select * from myorder;
设置 mysql可以远程连接:
mysql>use mysql;
mysql>update user set host='%' where user='root';
mysql>flush privileges;
|
|