准备好mysql的离线安装文件:
MySql官网下载mysql-5.7.25-1.el7.x86_64.rpm-bundle,并复制到/usr/mysql文件夹中。
删除CentOS自带的MariaDB:
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs
rpm命令安装:
cd /usr/mysql/ mysql-5.7.25-1.el7.x86_64.rpm-bundle
rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.21-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
启动MySql服务:
查看MySql运行状态:service mysqld status
启动MySql:systemctl start mysqld
查看root随机密码:
MySQL5.7会在安装后为root用户生成一个随机密码,而不是像以往版本的空密码。可以安全模式修改root登录密码或者用随机密码登录修改密码。下面用随机密码方式,MySQL为root用户生成的随机密码通过mysqld.log文件可以查找到:
grep 'temporary password' /var/log/mysqld.log
修改root登录密码:
MySQL的密码策略比较复杂,过于简单的密码会被拒绝
mysql -u root -p
mysql> Enter password: (输入刚才查询到的随机密码)
mysql> SET PASSWORD FOR 'root'@'localhost'= "123456";
mysql> exit
设置root可以远程登录:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
mysql>exit;
开启防火墙mysql 3306端口的外部访问:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
设置MySql忽略大小写:
用root登录,打开并修改 /etc/my.cnf;在[mysqld]节点下,加入一行: lower_case_table_names=1。
重启MySql服务:systemctl restart mysqld
来源:oschina
链接:https://my.oschina.net/u/4382516/blog/3303024