CentOS 安装mysql

来源:互联网 发布:ip更换软件 编辑:程序博客网 时间:2024/05/17 08:11

添加Yum仓库

  1. 前往https://dev.mysql.com/downloads/repo/yum/下载所需版本,如wget https://repo.mysql.com//mysql57-community-release-el6-9.noarch.rpm
  2. 使用

shell> sudo rpm -Uvh platform-and-version-specific-package-name.rpm

命令,如rpm -Uvh mysql57-community-release-el6-9.noarch.rpm。如果出现NOKEY警告,在命令中添加--force --nodeps

3.打开仓库文件vim /etc/yum.repos.d/mysql-community.repo,将所需版本打开(enabled=1),如

# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Yum安装

yum -y install mysql-server mysql mysql-devel

启动及登陆

启动

service mysqld start

查看状态

service mysqld status

设置初始root密码为root

mysqladmin -u root password 'root'

登陆

mysql -uroot -p

设置开机启动

查看mysqld服务信息

chkconfig --list | grep mysqld

若2、3、4、5为开启状态则无需其他操作,否则开启

chkconfig mysqld on

ubuntu 安装mysql

sudo apt-get install mysql-server mysql-client libmysqlclient-dev
0 0
原创粉丝点击