linux安装mysql

介绍:本篇将介绍centos、ubuntu系统安装mysql数据库教程

一、centos安装mysql

1、安裝 MySQL Repository
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"

2、安裝 MySQL 套件
yum -y install mysql-community-server

3、 启动服务
systemctl start mysqld //启动mysql服务
systemctl status mysqld //查看mysql状态

4、5.7查看密码
grep 'temporary password' /var/log/mysqld.log  //5.6默认没有密码

5、5.7进入数据库设置root密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

6、5.6直接进入数据库修改密码
update user set password=password('123456'),host='%' where user='root' and host='localhost';
flush privileges;

二、ubuntu安装mysql

1.检查系统中是否已经安装了MySQL
netstat -tap | grep mysql

2.如果没有安装,则安装MySQL
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server mysql-client

3.测试安装是否成功
netstat -tap | grep mysql

4.登录数据库(默认是没有密码的,登录进去之后修改密码即可)
mysql -uroot -p

你可能感兴趣的:(linux)