添加Yum仓库
- 前往https://dev.mysql.com/downloads/repo/yum/下载所需版本,如
wget https://repo.mysql.com//mysql57-community-release-el6-9.noarch.rpm
- 使用
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
网友评论