MySql教程

Linux安装Mysql

本文主要是介绍Linux安装Mysql,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1.安装wget

yum install -y wget

2.备份

cd /etc/yum.repos.d/

mv CentOS-Base.repo CentOS-Base.repo_bak

3.更换阿里云yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

4. 清除YUM缓存并建立缓存

yum clean all

yum makecache

5.查询mariadb并卸载

rpm -qa | grep mariadb

rpm -e --nodeps mariadb-libs-5.5.65-1.el7.x86_64(复制当前环境的mysql)

6.下载mysql的repo源并安装rpm包

cd /opt/

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

7. 安装mysql

yum install mysql-server -y

8.授予权限

chown -R root:root /var/lib/mysql

chown root /var/lib/mysql/

9.重启mysql数据库

service mysqld restart

10.登录mysql数据库并授权

mysql -u root -p
​
use mysql
​
update user set Password = password('ok') where User='root';
​
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "ok";

 

11.使配置生效并退出

flush privileges;

exit

12.安装vim并设置字符集

yum install -y vim

vim /etc/my.cnf

添加

character-set-server=utf8

13.重启mysql

service mysqld restart

14.登录mysql数据库

mysql -uroot -pok

这篇关于Linux安装Mysql的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!